Spring MVC view technology: what to choose? - spring

I want to create web-site with Spring back-end, but I can't choose what view technology to use: JSP, Velocity, or I should try to integrate JSF with my app. Which of this technologies is the most popular?
Looks like that JSP is a quite deprecated technology, but I hasn't found a proof of this thesis yet. Should I learn JSP, or try some another framework?

I´d use JSP+JSTL+Tiles, but mainly because everybody knows them. I could consider to use Freemarker or Velocity (Specially the first). However, I think Spring MVC and JSF are technologies that overlap, and using them together could be useless and dangerous.
I recommend you to take a look at this: http://docs.spring.io/autorepo/docs/spring/3.2.x/spring-framework-reference/html/view.html
And also at this: http://ihatejsf.com/

Related

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

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.

What the difference between struts2 and spring MVC

I am learning Java EE and wanna build up a complete management system for a restaurant. Now I am confused what presentation layer should I use for my RMS because I heard that the struts 2 is one of the best UI layer but, the thing is, if I am using spring for my business logic layer then I can use the spring MVC can't I? By the way, I am really interested to build a complete application which is follow the multi-tier architecture.
Yes, of course you can use Spring MVC.
You can use Struts 2 if you'd like as well, because Spring integrates with it nicely.
But I don't see any reason why you'd want to do that. The person who told you that Struts 2 is
one of the best UI layer [sic]
is misguided. If you compare it to Spring MVC, you'll see that the two are based on similar ideas, but Spring improves on Struts. JSF has superceded Struts as the default Java EE web view technology, so it's not even considered "best" by the Java EE standard.
Stick with Spring. You won't be sorry.
I will not blame struts 2, indeed it's a great product, I work with it every day. But in my experience spring MVC is a lot simpler and clearer. This doesn't mean you don't get as much features.
Try both, and you'll see what I mean.
Tell us which one you choose!

Choosing Presentation layer for spring application?

i was using JSP and YUI with spring applications
and i want to use a new presentation layer like IceFaces or GWT or any other good one
but i am confused what to choose
i need to make a good looking view, and the technology must have a good support/samples, and easy to use, commonly used with spring, please advise, thanks.
I don't have enough experience in IceFaces, but GWT is really easy, rapid and full ajaxian. Also the SEO issues can be handled in GWT.
Although a bit old, check out:-
http://woork.blogspot.com/2009/01/10-beautiful-web-ui-libraries.html

DOJO with spring framework

I am new to Spring as well as Dojo. I need to use Dojo with one of my mvc project in Spring 3.0
I came accross below link which talks about using spring-js with Dojo.spring-js part of spring framework?
http://static.springsource.org/spring-webflow/docs/2.0.x/reference/html/ch11.html
I could not really follow that link, is there any step by step tutorial which will show me how to use dojo with spring framework 3.0 ?
I need to start with simple things with Dojo like client side validation of forms.
Thanks in advance!
This is a tough question to answer, because it turns out you don't really need to worry about how Dojo and Spring interact. Your client and your back end server are completely unrelated until you decide to send data back & forth.
So for dojo, you probably want to look at how to use some of the form validation. Take a look at this link for some help on that:
http://o.dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/form-validation-specialized-input
Once you have some validation in place, your form can use the normal form post to post your data to the server, same as how you would do it without javascript.
On the other hand, if you want to add some nice Ajax to your application, take a look at this link which explains how to implement Jackson marshalling/unmarshalling to send JSON data to Spring & handle responses correctly.
http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/
Spring Roo uses Dojo, so you can create a Roo Project and have a look like they did it.
For Spring, You can follow this tutorial (Its the most compact and covers all basics):
http://www.tutorialspoint.com/spring/index.htm
And for Dojo The best tutorial is at: http://dojotoolkit.org/features/desktop
(in Create Beautiful User Interfaces subheading youll find all the APIs and their examples)
Its the way I learnt it. :)
Cheers

Spring MVC View

What are you guys using for your view in Spring MVC.
I know Spring MVC has a wide support for views but I'm having trouble finding what works well, what view to use when, etc.
Any insight would be great!
JSP, of course.
Sometimes PDF; Excel when necessary.
BlazeDS makes Flex integration with Spring possible. That's a great way to go if you use Flex.
"...I'm having trouble finding what works well..." - they all work well from Spring's point of view.
What to use when? Use the technology that you know best. Spring can deal with all of them just fine.
UPDATE: Since this was written three years ago, I'll amend it by saying that I would recommend just using Velocity templates to marry with dynamic data. Templates should use HTML, CSS, JavaScript, and jQuery. I think that provides the best flexibility you can have. You "future proof" your design if you can generate responsive HTML 5 pages.
We are using the following templating languages
Apache Velocity: Most of our old projects are using apache velocity to render the view. This is a very easy to learn and use language. But here xml operations are very limited.
Freemarker: Now we are migrating our project to Freemarker. This is a very good templating language. Advantage over velocity is that it has a very good support for xml data processing
You can use jsp with struts tiles to give good and uniform experience. You can refer to "Spring in Action" Book to find out how to do it. I have used this combination for developing my website www.propertymela.net. Have a look.
I am using Thymeleaf, because it has static prototyping which is very useful when there are two teams doing web design and server side development. I believe JSP is a fairly old technology, and I've had some problems with using HTML5 with it, which is why I opted to use a different view technology.
Also, Velocity is a competitor of Thymeleaf but I haven't really touched on Velocity aside from creating email templates.
JSTL is my option. JSTL has all the functional component which we can achieve through the use of scriplets in JSP. The avoidance of the scriptlet code in JSP is key to move into JSTL
In scriplet code if anything wrong whole page breaks. But it is not in the case of JSTL

Resources