Desktop-like UI implementations for Java web applications? - java

At work we're discussing upgrading our view layer for our web application. We're currently running an old and "modified" version of FreeMarker Classic, which is a pain to work with. One of our developers suggested using a Component UI style architecture similar to desktop style environments.
Essentially, this would mean that you would build custom HTML components as Java Classes that the controller would render into the Document view. This would completely take away the need to write HTML into a view layer. The Components would generate the view layer for you.
For instance, the following rendered HTML:
<h1>I am a title</h1>
<p>I am a paragraph.</p>
Would be generated by doing something like:
String titleString = "I am a title";
html.elements.Heading heading = new html.elements.Heading(Heading.H1, titleString);
String paraString = "I am a paragraph.";
html.elements.Paragraph paragraph = new html.elements.Paragraph(paraString);
PrintWriter somePrintWriter = new PrintWriter();
Document document = new Document();
document.addElement(heading);
document.addElement(paragraph);
document.compose(somePrintWriter);
The above code is just an example, don't critique the names or style, I just wrote it for a quick demonstration of what we may be trying to accomplish. I'm trying to determine if this has been done before in Java, and if so if there are any links I can be pointed to. I've been researching it as much as I can, but haven't found any implementations that completely remove the template layer (such as JSP or JSF).
Thanks!

There is a pure Java way where EVERYTHING is built using Java. Check it out here
http://www.zkoss.org/
UPDATE: I found even better one. Also pure Java. http://vaadin.com/home

How about GWT?

Echo2/Echo3 might be useful.
Echo is a platform for building
web-based applications that approach
the capabilities of rich clients. The
applications are developed using a
component-oriented and event-driven
API, eliminating the need to deal with
the "page-based" nature of browsers.
To the developer, Echo works just like
a user interface toolkit.

I used GWT-Ext to create a desktop-feel for a Java-based web app. It was very well received and feels very much like you are not within a web browser at all.

Click is pretty close, to what you are describing. It does use Velocity, but if you take a look at the Advanced Forms example, the template was very basic.
wingS is another one that looks to be close to what you want. It is supposed to be Swing like.

Related

How to use CSS graph in java

Is there a way to implement good design graphs in java?
I come from web front end, and I'd like to create graphs with amazing style effect in java - Just like how I would do in javascript and CSS?
Something like this:
You can take a look to those libs:
JfreeChart
JavaFX
I can miss some others.
I built a month ago an J2EE app (with servlet and JSP page) and I had to deal with charts and honestly I dropped the idea of doing it in Java. The reason? The difficulty of finding a good API/lib and the poor documentation of these.
I personally chose to use AngularJS and my data are produced with a Java program (NOT telling you that's the best method).
My charts are made with Zingchart. I found it very powerful due to the fact that the charts can be made from JSON (easy to make in Java).
Hope I helped you.

making a browser without using JTextPane or any other class that reads HTML

Good evening, I'm working on a project with a team, we have to make a browser without using JEditorPane or any other class that reads HTML.
How can we do that? Do we need to make a new class that does what JEditorPane does? Can I find somewhere JEditorPane's code? Thanks!
Well, this is an answer:
If you need to display web content without using any pre-existing engine (such JEditorPanel or a ChromeBind), you need to read the HTML as a XML file and construct your native View based on it (without CSS and JS this is a fairly easy task) by constructing the screen based on a one-to-one equivalent of a HTML tag to a Java JComponent.
Modern Web Browsers are pretty complicated, so there are a lot of different pieces that come together to display a web page. In order to build a browser, you need to first understand what a browser is. For that, I recommend reading this tutorial.
Once you have an understanding of how a browser actually works you need to determine which pieces you can reuse and which pieces you have to write from scratch. Do you have to write the entire rendering engine? Good luck! Can you use an existing engine like Gecko or Webkit? Or maybe you can get a little closer to done and use the java port of Webkit?
Once you have a better understanding of the question come back and ask more direct questions when you get stuck at a specific piece. As it is, your first step is to gain an understanding of the problem you are trying to solve.

Web UI for existing Java application

I am trying to build a search engine using java and the lucene API as part of a project. For the last step, we plan to build a web UI (a local host would do) for the same. Are there UI softwares/plugins for eclipse which will allow me to call the functions present in the java classes?
Essentially I would want to have a search box and a search key, pressing which will throw up the search results(which is computed from the java program). javascript cannot call java code I understand. So using that is eliminated?
Any suggestions on what to use will be greatly appreciated. I have pretty poor knowledge in front end design!
Cheers!
AB
If all you have is a simple screen with a entry field and a button and you simply want to return an html table. I would go with a servlet and two jsps. Your servlet can call your search engine and then have the jsp format the data into the table. If you do not know web apis this is probably the easiest entry.
I think, If your using JAVA, that you should look into JSF.
It's a rather easy to maintain and work with library for just the uses you describe.
I recommend these tutorials to get you started: http://www.coreservlets.com/JSF-Tutorial/jsf2/#Tutorial-Intro
There are lots of options to achieve this.
you can create web-ui using jsp.
I have also created same type of project using Lucene, here i have used spring mvc.i have provided all the back-end process as REST api which any web-ui can use.
Please do not look into JSF; it is an overengineered pile for your task.
Sure you can call your java code from javascript, you can make it really simple with something like DWR.
However, for your project I would suggest GWT as then you only deal with Java and it will generate javascript, html and css for you.
For your project you dont really need an "enterprise" level framework like spring or a fullstack JavaEE, you could keep it real oldschool with only JSPs and html/javascript. However thats a bit too flaky for my taste, so go with GWT.
With GWT you basically set it up, define your module, entrance point (look at the hello world), and then you add a layout to your page like something to place the searchbox into and the resultbox to. Then you call your other Java code and classes from there like you normally would.
I would suggest you to use GWT in your application because GWT enables you to call java methods and it will also convert Javascript and css for your Java modules after GWT compile.
GWT reference :- http://code.google.com/webtoolkit/gettingstarted.html
If you're going to use GWT, you could aslo check Vaadin.
Creating a search UI is really simple, and the tutorial show a criteria /result table application taht could be adapted.

Converting Swing app to web

I have Java code of the algorithm that has numeric values as its input and output. The GUI is implemented as Swing in Eclipse. Now I would like to tranfer to the web environment and create the web-tool using JavaScript or sth like this. Is there any way to use the Java code of my algorithm without rewriting it?
if your logic and goi all together at the same class you need to remove all the GUI part and stay with all the logic. after you have logic class you can use what ever goi you want(swing, html, jsf....)
Another alternative is to skip the HTML part by hand and just create your HTML app in Java. No need for separate servlets serving Java validation to your HTML inputs. The open source framework Vaadin that we've been working on since 2001 and it has an almost 100% similar API to Swing could be an alternative for this for you. And it would hopefully save you a lot of time.
As a swing developer the most relevant starting point for you would be: https://vaadin.com/swing
You can look up in to servlets and if you do it in netbeans then will be much easier for you.

How do I translate a page in java with lot of text,without using resource bundle?

I have a web page with lots of text.Is there any means through which I can translate it,without using resource bundle(which involves using properties files,requiring key value pairs for all words.)?
Thanks for your precious time.
An alternative is to create separate views for each language. So a "mypage_en_US.html" for the US-english version and a "mypage_en_GB.html" for the british-english version. This gives you total control over the text and layout but has the drawback of possible code duplication if there is any logic in your view.
Wicket uses pretty clean views which should hardly contain any logic so this works pretty well there.
Just be innovative here. If you are getting shitty copy pase work. Write a program to convert the properties file and then use that properties file using google translate api, but yeah end of the day you will have to go with properties file.
I belive there would be other way too using google translate api again, would love to hear that myself too
Depends on your web framework.
For example, Wicket can apply I18N on webpages in two ways :
- using I18N files and resourcesbundles, with placeholders where required in the page
- by having totally separate pages, one for each language. The page template itself is postfixed with the locale, much like property files : HomePage_en.html, HomePage_fr.html, etc.
Other web frameworks may have similar features. If you're using raw JSP/Servlets, I'm afraid you're pretty much on your own.
But it's totally possible to implement your own templating system. For example, you could use a set of Freemarker templates, and load the one that matches the desired locale.

Categories

Resources