开发者

Frontend ajax framework work with Grails

I have some knowledge about Flex and Java EE, they are good for web application deve开发者_Python百科lopment. 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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜