Do you need to use a framework to Ajaxify your java web app? - ajax

I am currently studying Java EE with Hibernate for a project. In The Web App I am creating I am planning to Ajaxify page contents, and Site wide audio player(Which I think would be implemented using AJAX).
I am using a JSP based MVC, no frameworks, Just Java EE and Hibernate. And I've heard that I need to use a Framework like JSF to be able to AJaxify may web-app. How true is this? Do I really need to learn JSF or other frameworks to be able to Ajaxify my web app? As much as possible I do not want to learn a new framework for now since it is a big learning curve. but if there's no other way to Ajaxify my web app, I'll study a framework.

You don't have to adopt any framework to use partial page updates and similar, you can construct and send requests "manually" with JavaScript, but this is much more tedious then using a framework like JSF, maybe coupled with a component library like primefaces.
EDIT: you can find an abundance of examples of ajax capabilities in the primefaces showcase. Primefaces uses JQuery internally.
EDIT2: I have found some resources on how to dispatch ajax requests with JQuery from a JSP page (I assumed that using JSP was almost equal to not using a framework ;)): here and here. I hope this is what you were looking for.

To add on #Kostja's answer -
I totally agree with him, with Ajax you just need to have a servlet to handle the HTTP requests, and proper JavaScript code.
Besides JSF,I would also consider to look at Apache Wicket - you can read here how Wicket handles Ajax.
The reason I'm suggesting Wicket is that it's more comfortable to some developers to work with somewhat more "component oriented" (swing-like) framework.

Related

Frontend ajax framework work with Grails

I have some knowledge about Flex and Java EE, they are good for web application development. Anyway when I try to write a typical web page that is based on HTML/CSS/Javascript, I think I should take a look at some new program language/framework.
I heard much good news about grails and finally decided to learn it instead of python, ruby, scale… But I still don’t have an overview of the whole structure. Grails is a backend framework like php, jsp, jsf right? So that probably means, it’s a replacement of Java EE in backend, then how about the frontend (need ajax functionality), what are people using with grails?
thanks
Grails is not a replacement, it is an abstraction around the tradition Java EE stack and some extremely popular libraries like Spring and Hibernate, that allows you to go faster by using "convention over configuration".
One component of Grails is GSPs, groovy server pages, which is a front end technology, the V in the MVC (Model View Controller) paradigm. You also have Domain Objects, which are the M (Model), and Controllers, which are the C. Grails also has Services which are best put into the M category (IMHO) of the MVC paradigm. So the Model arrangement in Grails gives you relatively easy persistence (using hibernate under the covers), the Services give you great reusability in your business and transactional logic, and the Controller simply invoke the right logic for a given request, and return the response.
One part of that response is what gets displayed on the screen. In a simple webapp, GSPs fill that role -- the controller tells the browser to render a specific GSP which has data bound to it from the service method that was invoked in the controller. However, it is easy to have the controller return json, so if the endpoint bound to the controller is an ajax request, the client can handle the response itself.
You can use any front end technology you want in a grails app. The default is GSPs, which is an extension of JSPs, which are part of the traditional java stack, but you can use jQuery, Sencha, Sproutcore, Backbone, anything you want. You would have one GSP in that case which bootstraps your javascript code, and the rest would be handled by the client application.
Grails is a web framework and is not just a backend framework. It supports both JSP and GSP ( Groovy Server Pages) for views.
If you plan to use Ajax functionality, you can make use of one of many javascript frameworks available. You can also go ahead with Flex (since you already know it) or use a javascript framework like ExtJs, Dojo, YUI etc...

Spring MVC 3 and Ajax library advice

I'm developing a webapp with Hibernate+Spring 3 (Spring MVC, JSP): I'd like to create some divs with AJAX style (i.e. no need to refresh all the page, independent update of each div).
I'd like a good advice about which AJAX library to use (in conjunction with Spring 3 MVC + JSP) and, if possible, where to find some code snippets.
I know very little of AJAX libraries, JSONs and how to integrate them, but I have good knowledge of Javascript and Spring (and how callbacks work). I'd like to write as less code as possible, particularly in the jsps.
My Webapp will display an updated (every 5 minutes) POJO in a div and perform some operations between different domain objects in the other div when user press a button.
This is correct use JQuery
Here
http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/
you can find working examples to use Jquery+JSON+Spring MVC.
and this question can help you with server side configuration:
JQuery, Spring MVC #RequestBody and JSON - making it work together
I would suggest jQuery. It is very easy to use and has very good ajax support.
In addition to that it has quite a lot of plugins and components.

Using YUI with Spring framework

i am new to ajax technology
and i want to use YUI technology with spring framework
so please guide me where to start;useful links & tutorials
thank you.
YUI is a Javascript library. Spring is a Java application framework. These are not directly related; ie, Spring has no YUI hooks or anything like that.
Spring MVC and Spring Web Flow can be used to build web applications, and web applications can serve whatever files you want, including any Javascript files you have.
Here is a list of YUI examples.
YUI is a client side js library, and has little to do with serverside frameworks; so, Spring and YUI are not related.
if your are looking to work with YUI2, or for YUI3. also yui-gallery is a good place to get started with the examples.
YUI Theater has a whole bunch of developer videos to help you understand the internals of YUI JS Library, is a place worth spending time

Add Ajax Support to Spring MVC

I would like to add ajax to an existing spring mvc 2.5 webapps. But i dont know where to start.
I think spring does not support ajax integration.
Does someone know how can I accomplish this? I was thinking that my ajaxrequest should be catch by the controller interface but I dont know where to start.
I dont want to use any ajax library at this point but just plain old ajax approach
Kindly send me links or tutorials if what I am thinking is possible please
Spring MVC does not provide out of the box Ajax support. However it provides suitable extension points through its template based design to enable Ajax support very easily. Still you can implement it using jquery library.

AJAX with Struts 1.x Version

I am having an application developed with Struts1.3, Jboss4.X version and jdk1.5
Now as an enhancement we are planning to implement AJAX to the web application
Can you please suggest me
Whether I can use AJAX with Struts1.3 Framework?
Which Jar I need to use if I Can implement AJAX?
At Some website, I realised struts2-dojo-plugin.jar can be used for Struts2, whether the same jar works for Struts 1.3 Version
Please clarify my doubts
Yes. You can use AJAX with the struts1.3 framework. AJAX is mostly done in the JavaScript on the client. It requests a URL on your server which will correspond to an action that you write. As far as the browser is concerened it knows nothing about struts, it just happily request pages assuming they are all static html pages.
You do not need any special jar files to use AJAX. In struts2 they included dojo making it simple to use that library without needing extra libraries. However, you can download and install any javascript library such as jQuery, dojo, prototype etc that will help you do AJAX.
Most likely not. the struts2 Dojo integration will not work out of the box in struts1.3 You can use the Dojo library if you wish but you will have to do it yourself.
Some links:
AJAX and Struts1 and Struts2
Justin Coyne

Resources