Which Java web development framework for an AJAX application? - java

I read through a few threads (simple web framework, java web development, etc). Very informative. However I have not seen a focus on the AJAX side of things. For the app I am trying to create, most of the client side will be written in Google GWT, and JSON will be used to communicate with the server side. In that case, all templating is pretty much useless.
For my purposes, which framework would be the simplest to setup and easiest to learn?
Thanks.
To clarify, I want a server side framework. GWT is great for client side, but I need something to generate json responses on the server side.

None at all, most likely: GWT is framework enough, given that's what you're using. The only reason I can think of to add anything else might be if there was some special effect you absolutely craved (but if you've chosen to go GWT, my recommendation would be to give up on such special effects),

Ajax/JS by nature functions mostly on client side and you want to use it but want to run it on server side? Are you sure you're not trying to hammer a square block into a round hole?
Reading through your question it seems to me what you're really asking is for a way to abstract a layer which provides JSON for your client side UI. Most web frameworks such as GWT deliberately abstract this part away but still include it in their inner workings: it would indeed be rather stupid for an Ajax web framework not to support data transfer between the view layer and the rest of the system!
However, if you really want to create your own custom component for serving JSON, then I suggest you take a good look at Servlets and mix that with any of the gazillion available JSON libraries listed at JSON.org.
And if you still really, really want to run your client side view logic on server, Vaadin could do the trick for you. In practice Vaadin really runs GWT on the server side and just serves static stuff generated by the server side GWT but from what I've understood the difference has been abstracted away.
A huge word of warning though, for me it sounds like you really want to reinvent the wheel here while you shouldn't. You really should reconsider your architecture and/or deepen your knowledge of GWT and web frameworks in general, the "framework" part usually hints that it's not just the V from MVC Model 2 but at least V and with M bindings.

I've had pretty good luck with the Dojo Toolkit. Make sure to download the full toolkit (Dojo, Dijit and Dojox) which you'll find at the downloads page.
Their 'Hello World' tutorial is pretty useful for getting started.

You could could give IceFaces a try. It's a Ajax framework based on faces technology. Works really great and magically, also comes with a good documentation and tutorial.

You should look at one of the REST based frameworks, like Jersey, Restlets, or RESTEasy.
The main reason is that these frameworks make binding and working with JSON easy. Most of the other systems are designed for HTTP POST encoded data, which is not JSON.

Related

What is the advantage of using Direct Web Remoting over a REST web services design?

I have an enterprise Java web application deployed in tomcat.
I am looking for ways to integrate a HTML & JS UI with the mid tier java code. So far, from looking around I have read that there are two ways to do this which fit my requirements :
1) DWR - Direct web remoting
2) Use REST web services.
I am not sure which approach to use.
Edit: What is the advantage of using DWR over a rest WS design?
Is there a better approach available? Some people asked me to have a look at GWT, but I am not sure if these are scalable.
Edit 2: I will most likely be using dojo for the UI development(Works well with REST/DWR??), and I want to keep the java code chages minimal. I understand that by using web services, I would have to write an additional WS client layer on top of the existing java code.
Also, the usual enterprise needs, performance, scalability, etc.
Ok so you're building a web client frontend to your java backend, there are a few ways to go about this:
You want to use java standards as much as possible, preferably living in the java EE world: JSF. You will need some knowledge of HTML, XML and perhaps even javascript (though limited). Personally I have had a pretty buggy experience with JSF+richfaces to the extent that I don't use it anymore.
You are very well acquainted with java desktop application development but don't know much about javascript: vaadin: it allows you to write plain java using desktop application terminology which will be compiled to javascript. Currently I am working on a big vaadin project and it is very nice to be working with pure java in eclipse, the downside is however that you are far removed from the actual frontend, so tweaking can be tricky. Additionally everything is stored in sessions (afaik) and scales poorly.
You are primarily a frontend person with unrivaled javascript skills: use a REST interface in java and a pure js/html/css frontend. Personally I think this is the cleanest design and I have designed a few of my own applications like this. The downside is that managing large javascript projects tends to be hard because...well...javascript sucks. The upside is that this will always be the fastest most lightweight option available to you.
Ideologically I would definitely suggest the last approach but this can be hard for large projects. If you have the hardware to throw at it, vaadin is a nice option. My JSF 2 experience was a bit disappointing due to the bugs in (necessary) third party libraries like richfaces.
PS: I have never heard of DWR but the last stable release seems 2 years old and all it seems to do is expose java code as javascript methods which can be better handled with a REST interface.
Open interface standards like REST and SOAP make it easy to build code to consume these services if you are using frameworks to build a REST Client and a SOAP client code respectively. But the point is that you need to have this client code to make calls to these services.
DWR on the other hand, generates this client code. Your java classes are ready to be called (like you would do in Java).

Modern HTML/CSS/JS layout together with a Java backend

Introduction
I am basically coming from two sides of the development teams. I started building web applications using PHP. This way, I had to implement everything by hand. Forms, graphical elements, how everything is tied together (i.e. what happens when you click a button).
On the other hand, some time ago I entered the Java Web world, namely JSF. Which is in my opinion a nice way to build a "serious" applications. (why I think so, read below)
Problem
I would like to build a web app that is made of a nice and useable frontend that is designed after my specifications (basically doing the HTML and graphical layout as a horizontal prototype first - as far as possible -, then make a complete webapp out of it). But on the other hand I would like to do all the business logic in Java because of its many nice frameworks out there - Hibernate, Morphia, Lombok, Dozer, just to name a few I met and fell in love with.
I could build the frontend with JSF myself but I still think, that I'm too limited because I have to use the built-in components that can only be customized to a certain amount. What if I want to use my own design patterns and UI elements and behavior but still want them to work together with a Java "backend"?
What would be the "best" choice of tools to achieve my goal? Choose a different web framework like Wicket or similar?
My idea: Build a web application in Java that understands the good old GET commands and translates it to the Java methods. Sort of a RESTful service - although I'm not a great fan of making everything RESTful in the frontend - unless you tell me, that's fine and reliable.
Have you considered / looked at Google Web Toolkit for what you're trying to craft?
GWT is Java behind the scenes yet still can get you where you want to go, if I understand what you're asking.
Just an update:
If GWT isn't your thing, take a look at the Groovy / Grails route.
Just some elaboration here based on a comment...
With Groovy/Grails you don't actually have to merge your front and back end. I have seen that done, but its not necessarily always 100% required.
For example, you could create a web app in Grails where your AJAX functions could be formed and stored with the UI code being delivered out to the client for Great-UI-Justice. For added fun, you can even instruct Grails to include a JS framework such as jQuery to help you out with the UI.
Now on the back end, you should be able to take your Java back end and apply it directly with little to no change. However, I would recommend looking into adjusting anything you've done so far to take advantage of the Grails methodology.
There are many JSF libraries like ICEfaces,
RICHfaces etc, that make use of things like AJAX, etc.
In my personal opinion it's always a good idea to have a RESTful API and treat your web page just like any other client ;)

Guidance Creating a "Basic" Java Web App

I have limited exposure in creating a Java web app from scratch, and was hoping that some of you folks could help provide me with some insight.
Basically the flow of the application is as follows:
1.) User logs in (Authentication + session handling)
2.) Requests containing XML are passed to the server
3.) Responses are in XML format also and parsed by the client side
Are there any type of frameworks I can use to help me out with adhering to the "best practices" for what I want to accomplish? I'm comfortable with being able to handle the XML/DB interactions, however I'm not too comfortable with the auth and session handling.
So far I've gotten to the point where I'm using Jetty as a servlet container, and coded basic functions to handle hitting the DB. I'm sort of lost on properly implementing the rest.
I was thinking about using SOAP but it seems like overkill?
Any advice would be greatly appreciated. My apologies if this is a silly question to ask, but after searching for hours.
thanks!
-bp
This is a very broad question, so I'll just give a partial answer. As far as using SOAP, its main practical advantage is for interoperability.
However, it would also be easier as a developer than creating something from scratch: both Axis2 and the Java Web Services Development Pack come with very easy to use code generators (the latter made easier w/ Netbeans or Eclipse). You would basically mark up the code you want to expose as a web service by using annotations (examples abound on the web) and then run it through a code generator and run it. This will produce both the client and the server code. Do some research on Axis2 and Java WSDP.
Implementing security with this solution is trickier. But using headers you can exchange encoded login information.
Using a web framework might actually be overkill if all you need is a webservice as opposed to a human-accessible app through a browser.
EDIT: I should add that the web services solution above, as an added bonus, handles all of the xml for you, although implementing security headers will require some knowledge of SOAP and maybe security standards. It's probably best to make these high-level decisions and ask more specific questions here as you go along.

Java MVC and Rest Server and JavaScript Heavy Client

I am in the process of beginning development of a web-based user interface and am looking for some expert advice on the right direction for my project.
Since our server-side is to be developed using Java, I am planning to use scriptless-JSP and an MVC framework called FrontMan. FrontMan is a lightweight Java-based MVC framework similar to Struts. I have played around with it and like it. The plan is to use scriptless-JSP assisted by JSTL and JSP tag files. I worked out some prototypes using these technologies and I liked what I had.
Now I am in the process of planning out the client-side stuff. My plan is to use JavaScript, jQuery, jQuery UI to build the front end. During my investigation I came across a very nifty JavaScript MVC framework named JavaScriptMVC. I have to say I really like it. It is not just a client-side MVC framework, but also includes tools for testing, documenting and deploying.
The more I engage in figuring out the client-side plan, I realize that I think this is going to be more of a JavaScript (client-side) app. I am leaning towards doing as much of the work in JavaScript rather than on the backend via Java. The backend will exist mostly for communicating with the database and responding to requests from the client (frontend) for manipulating or retrieving data.
I am rather new to RESTful web services, but in the little I have read about them, I think this might be a good direction to take this project.
I am wondering how I can employ both an MVC framework and REST framework together? Do they make sense together?
I am using Jetty as my web server, so I think that lends itself to using Restlets...?
Anyway, I am not sure how much sense I am making in this post, so I will stop it there for now.
As the previous poster mentioned, it makes perfect sence. MVC let's you separate concerns such that you can keep your application logic separate from your presentational logic.
Your REST controller serves the request you need, populates the model, and exposes it in a REST like manner, typically by returning an xml view to the user. This can be aided by a number of libraries such as xstream, jaxb, castor, xmlbeans, which all provides routines to marshall an object into xml.
Exposing a REST API on the server-side will be a perfect fit for your JS front-end. Your resources will have to expose JSON representations. You will even be able to reuse this web API from other clients such as mobile phones.
As the lead for the Restlet Framework, I can only recommend it for this purpose. Integration with Jetty is very stable :)
Cheers,
Jerome
A quite extensive discussion on this can also be found here:
Separate REST JSON API server and client?
For me it was very helpful.
Yes! It makes sense as Johan Sjöberg said! You can use Spring MVC for example. I like it a lot and think it is very simple and easy to learn. You have an example here.
By the away, for the frontend maybe you would like to check this presentation.

Best server-side framework for heavy AJAX Java application

There are zillions of Java web application frameworks.
95% were designed before the modern era of AJAX/DHTML-based development, and that means these new methods are grafted on rather than designed in.
Has any framework been built from the ground up with e.g. GWT + Extjs in mind?
If not, which framework has adapted best to the world of forms with dynamic numbers of fields and pages that morph client-side?
Echo2 / Echo3 by Nextapp (www.nextapp.com) is totally awesome.
Advantages over GWT:
1) It is not limited to a sub-set of java like GWT
2) It is easier (in my estimation) to learn
3) Has extremely robust design studio for almost drag and drop designing.
4) It is very fast, and works very well on all platforms browsers
5) You can write your application using either java script or java
6) It has great and straight forward methods for handling events and actions.
Personally I think that for any web-application in which you are trying to integrate java and speedy delivery I wouldn't hesitate to pick Echo3 or Echo2.
If you're starting from scratch. I'd have to say Google Web Toolkit. I have to say it is incredibly powerful. You get keep using most of your Java tools. Plus, you don't have to duplicate code that exists on both the server and the client, it just gets compiled differently for each area.
I'd consider REST-style frameworks as well as the other recommendations here- Restlet or Jersey may be good choices for the backend, while you use something like JQuery or GWT on the front end. Both frameworks can easily produce JSON, and the REST style provides a nice clean line of demarcation between your client application and your server source; I find that JSF can make that demarcation pretty muddy.
I use JSF and IceFaces. Although JSF has a few limitations, IceFaces seems to work pretty well and has ironed out a few of the problems with JSF.
I haven't used a really good AJAX Java framework as yet, although Echo2 looks interesting.
I like the stripes framework. It lets you use whatever javascript toolkit you want.
Here is their documentation on AJAX
GWT is quite powerful and easy to use (all Java, no Javascript/HTML/CSS coding). If Google has their way it will be a dominant framework/tool in web applications development, and for good reason. It already works with Google Gears (which allows offline access to web apps) - and more than likely will be optimized to work within Google Chrome.
DWR
I use this to dynamically populate drop downs, and even filter them on the fly based on user input in other places on the form.
I like the combination of JBoss Seam and Richfaces, especially with the JBoss tools that are extentions to Eclipse - makes building these sort of RIA's incredibly easy.
Wikipedia contains some useful comparisons:
Comparison of JavaScript frameworks
List of AJAX Frameworks
Your choice depends on several different factors including whether you want the "work" done client-side (most javascript frameworks) or server-side (echo2 etc.). Other things worth looking at are tools like OpenLaszlo that provide Flash (I think) out of the box, but drop back to DHTML if there is no Flash player present.
Unfortunately I think the decision comes down to balancing several competing cocerns. Check out the comparisons and try them out - most come with online demo's for you to try.
Aptana has a server side frame work called Jaxer. This is from their site:
Jaxer's core engine is based on the same Mozilla engine that you'll find in the popular Mozilla Firefox browser. This means that the execution environment you use on both the client and the server are the same. It's Ajax all the way through and through. That means you only need one set of languages -- the languages that are native to the browser -- to create entire applications.
This framework is open source and has a very nice IDE based on Eclipse. Aptana is also working on a Javascript implementation for ActiveRecord called ActiveRecordJS. Potentially you could use this both client and server side with their framework.
GWT is one of the best AJAX framework that I used ever. Most important thing about this framework is that its maintained by Google. And Everyone know "Who is Google ?"
GWT is used by many products at Google, including Google AdWords and Google
Wallet. It's open source, completely free, and used by thousands of
enthusiastic developers around the world.
GWT provide rich widgets that can be used to built any application. Almost all the widgets they have.
Another important point is GWT is continuously developing and its also have stable release which is very good thing. Another thing Google has also released GWT-Material which is again a very good thing because everyone is moving toward material.
I hope this will help you!!!

Categories