开发者

Which Java web framework is best if want to use jQuery

I am very good at jQuery and have used it in many PHP websites.

Now I want to only choose that Web framework by which I ca开发者_如何学JAVAn use jQuery to the same level as PHP, but in Java.

So, which web framework should I go for?


As you already have heard, component based frameworks are a bit wonky when it comes to using certain JavaScript libraries. I have personally used only a few so I can't create a definite list of them. I do have, however, used both component and template based frameworks so I'd dare to say that I have at least somewhat educated opinion to express on the matter:

In general, component based frameworks are usually a bit harder to work with mainly since they integrate the "Ajax channel" to their own internals. As an example, the currently very popular Apache Wicket implements all of its Ajax stuff natively which, at times, does show as being broken on certain platforms et cetera. The reason for this integration usually is so that the developers of the framework can rely on the behaviour of the Ajax functions in their framework completely; by making a custom implementation, they can lean on it and potentially debug it faster. There are of course exceptions to this (even Wicket has its own jQuery implementation called wiQuery) but even then that integration may be subpar to what you would be able to write normally.

Now, request based frameworks as you call them (I'd categorize them as template based frameworks based purely on my experience) usually allow you to have more fine grained control over various parts of the page, usually you end up even writing the final markup with some magic tags here and there for linking the dynamic part of the web application with the static layout. With this in mind, it's rather obvious that these usually allow you as a developer to choose - among a lot of other things - the JavaScript library of your choice, but it's a trade-off; whatever the component based framework would provide at this point is something you need to reimplement by yourself. Most commonly this is limited to handling Ajax requests but that varies from framework to framework.

To summarize, if you really want to use jQuery (and why wouldn't you) and you can't agree with the way it has been integrated in component based frameworks, look what the other kind has to offer.


If I had to recommend something that I would believe would fit you perfectly, I'd recommend GSP on top of Spring MVC using plain Java for backend stuff and such, but this combination doesn't actually even exist since GSP is the view part of Grails, a Groovy based web application framework.


For Java, I would suggest Spring's REST framework, where you can use JSON in your requests and your response. By using JSON to return your data back to the client side, you could use JQuery to parse the JSON, manipulate the data, and then manipulate the HTML document programmatically.

The advantage of this method is that it makes it easier to keep your content, behavior, and presentation separate. If you're working on a project with a design team of varying programming backgrounds, and if your HTML/CSS skills aren't as good as theirs, this method can be very powerful for maintaining a separation of concern.

Other than that, any framework could work, as JavaScript and server-side languages run in completely different environments.


You mean which MVC framework? It shouldn't matter. JQuery or any other Javascript framework is independent of what Java Framework you use.


I would recommend grails (without scaffolding, and without main layout: design your own layout using css and jquery (validation, date-picker and stuffs)), but since it uses objects a lot sometimes your application can run out of memory and you would require to allocate large memory. You can't avoid some of the places where you might not want those heavy stuffs(since every declaration creates getter and setter implicitly), but application development in grails is very fast, you will have a habit of using cool things as versioning in current data (but if you have transactions, then why do you need those, I don't know), if you don't want to get into the nuisance of scaffolding, but still want to see it as a reference then you can have two copies(one code generated from scaffolding) and other without it, so that you can develop your own version with carefully crafting the application with a reference to the scaffolded version. You should definitely give it a try before using 50 unrelated things in java(always nuisance) to just develop a simple web site.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜