Spring MVC with a rich client framework - java

I have several applications that are structured as follows
DataComponent
WebComponent
ThickClientComponent
WebServices
The DataComponent has all the functionality required to access the application's data so it contains the DAOs and the JPA entities. The other three modules are:
WebComponent - A spring MVC application that uses the DataComponent for data acccess
ThickClientComponent- A Swing application that uses the DataComponent for data access
WebServices - A SOAP based services that also uses the DataComponent.
All three projets have the DataComponent as a dependeny in their Maven POM file.
I would like to use a rich client framework like RichFaces, icefaces or primefaces as i need to be able to use the rich components are available in rich client frameworks (i.e. trees, panel, drag and drop etc).
I have looked around and i cant seem to find an example where a Spring MVC application uses a rich client platform. Is it possible? Are the rich client platforms a framework meaning that i have to use either Spring MVC or the rich client platform but not both?
The DataComponent module is spring based.

I suggest you to go for GWT. It is a very good rich client framework and it has a very huge set of components available including drag-and-drop. Also it provides the integration with Spring Framework. You can check out this and this links to know more about its integration.
I have also used smartGWT that is extension of GWT components in one of my project that has backend in Spring framework.
Hope this helps you. Cheers.

Maybe this module will sort you out:
http://static.springsource.org/spring-webflow/docs/2.0-m1/reference/spring-faces.html

You can try ext-js for creating your client side interface. It's heavily java script / ajax based, but that would probably meet your needs. It doesn't really care what your backed tech is, since it works entire through javascript and ajax.

Yess you can use Spring MVC with PrimeFaces but you have to use it with the spring JSF 2 implementation.
If you are thinking to use some faces framework definitely use PrimeFaces.
You could use SpringMVC with JSF but I also recommend to you not to use SpringMVC JSF implementation. Use insted the MyFaces JSF 2 implementation with Primefaces and then link the backing beans with spring.
From my experience this is the best.
But I guess any other options are fine too.

Related

Can Spring MVC be used to implement MVC pattern in Swing applications?

I was wondering if Spring MVC can be used to implement MVC pattern in Java Swing Applications. I've done some study and found Spring MVC to be used for web development.
Is there any way Spring MVC to be used with Swing Applications?
Not really. As you say, Spring MVC (or Spring Web MVC) is primary targeted for web server development and thus have little to do with client side or standalone GUI applications.
That said, nothing prevents you from using ordinary Spring technologies for dependency injection, as a backend in your model, etc. Spring provides abstractions for persistence, remote network communication, transactions, security and so on that might come in handy in many projects.
Additionally, there is the Spring Rich Client Project that was released some years ago, but I do not know its current status.
No, but you may want to take a look at Griffon, which offers a Swing MVC framework base on Spring libraries and the Groovy language, which should be really easy for any Java programmer to pick up.
I've used it quite successfully to build rather large desktop applications for corporate clients.

JSF or JSP 2 Tag Files for new project

I have a requirement to amalgamate functionality from some parked Java side-projects into a new application and am trying to make a decision on some of the third-party libraries to use, specifically relating to the UI. I would be very interested to get some feedback from tech arch oriented members on their views in relation to recent java framework trends and experiences.
The legacy projects are a mixed-bunch, all web-based, lots of business logic around CRUDable objects with searches. One uses an in-house framework - very fast, scalable, but with the disadvantages associated with in-house work - learning curve for new devs etc. Another, a Tapestry 5 app - very robust, terrific integration with XFire / CXF for generating web services, rapid UI generation, but with a good learning curve for non-Tapestry types. The third, a Spring 3 app, using JSP 2.0 Tag Files for view layer, with some sprinklings of JQuery for presentation / ajax.
I'm very familiar with Spring and find tag files for the UI with Tiles very effective in terms of low-complexity and performance. I have also recently wrapped up a project that used RichFaces 4 which was successful and came in on time. I like the rich UI that comes for free with RF / IceFaces etc., and have noticed that JSF in its more recent versions has retired JSP altogether.
To cut to the chase, is the restriction of using a component based UI library with clearly defined but unmodifiable behaviour like RF / IF a better fit for a new app than a roll-your-own solution, with tag files / JQuery. I'm more familiar with the latter, but don't want to go down the wrong path at this early stage of a project by adopting an out of date approach. I want to continue using Spring 3 Controllers for RESTful, bookmarkable application entry points - do IF / RF mix with Spring or does a JSF approach remove the MVC obligation completely from Spring?
If the MVC obligation is removed from Spring:
how would the JSF lifecycle integrate with Spring - would it be self-contained and just use IOC for wiring Spring services?
is there good integration with a IF / RF approach for generating web services etc.?
what kind of support do IF / RF have for tablet / mobile?
is Spring needed at all - would managed beans do the trick?
To cut to the chase, is the restriction of using a component based UI library with clearly defined but unmodifiable behaviour like RF / IF a better fit for a new app than a roll-your-own solution, with tag files / JQuery.
It is not one or the other. Java Server Faces is a Component Based Web Framework that allows for the synchronization of server and client state on requests and responses to allow for things like a phase and event model in your applications. Many JSF components utilize jQuery inherently and expand upon rich client controls by wrapping them in server side behavior. It is not unmodifiable behavior by any stretch, just that there is a bit of a learning curve to customize things in a very specific way.
JSF is currently the Oracle recommended approach to Java EE web development.
do IF / RF mix with Spring or does a JSF approach remove the MVC obligation completely from Spring?
how would the JSF lifecycle integrate with Spring - would it be self-contained and just use IOC for wiring Spring services?
JSF is inherently its own MVC framework and with managed properties already has its own baked in Dependency Injection. Core Spring is primarily Depedency Injection so one would think that they are at odds but surprisingly they go together well.
Recent versions of Spring have provided their own EL Resolver implementation for JSF that allows JSF Managed Beans to be handled as Spring beans. This class can even be backfitted into older versions of Spring, which I have done and noticed no issues.
Spring MVC is primarily built on JSP technology, but it is not a core part of Spring. You simply need not include it in a JSF web application if you don't wish to serve JSP pages.
is there good integration with a IF / RF approach for generating web services etc.?
When it comes to web services in a JSF application it is best to remember that JSF doesn't have to define limitations on your web app, nor does it have to define it in its entirety. JSF is merely the front end for JSF page requests. Knowing this your same web application can also serve SOAP or REST based web services of their own, or simply handle these web services at data sources on the server side in your business logic. Another way still is to call external web services from Javascript on your page. Nothing in JSF precludes you from incorporating any element of HTML, Javascript or even newer HTML5 technology.
what kind of support do IF / RF have for tablet / mobile?
Not sure what IF and RF have but I know that Primefaces has an impressive control set for mobile applications that is worth checking out.
is Spring needed at all - would managed beans do the trick?
No absolutely it is not needed. I happen to like Spring though so I use it.

Java Equivalent for ASP.NET MVC Areas

Areas, in ASP.NET MVC, are handy for breaking a site into smaller, manageable components at a higher level than controllers. They are like mini-MVC pieces within a web application.
Is there an equivalent concept in any Java MVC framework to ASP.NET Areas?
If not, are there any suggestions on best practices when emulating their functionality in a Java MVC framework?
Try Spring MVC. This may be fulfill your wish.
Look at JSP Tiles and Velocity Templates. Tiles should look similiar to Areas.
Take a look on this Web Framework for java: playframework
As such, Java EE does not provide an out of box solution based on MVC but there are many OpenSource projects that have created a solution which implement a MVC framework - try the latest Spring and Struts versions.

What is the best approach to use Vaadin for web application development?

I am just about to create a new Web application (kind of CRM system) with lot of tables, statistics, graphs, etc... and I've decided to do the web interface with Vaadin. Most of the data will come from external Web Services (almost 100 %). My Question is, what would be the best approach to go with? Just to implement pure Vaadin application and some classes to handle the SOAP calls and fill the Vaadin components with the data, or to go with some additional framework e.g. Spring, Struts, etc... and integrate vaading for the UI? Any additional hints would be great.
Thanks
Filip
Using spring is good for dependency injection, security (depending on the sections you are using) but struts and vaadin are web frameworks so mixing them does no sense. You either use struts or vaadin or spring-mvc or any other web framework.
Your question is not really clear but I would say you can use spring rest api to pull data from other web services if they are restful services.

What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?

May I know what is the difference between:-
Spring
Struts
Struts 2
Hibernate
JavaServer Faces
JavaServer Pages
Tapestry
Are these technologies/framework complementary to each other? Or they are alternatives to each other (after I use one of them, then I don't need to use the other)?
Thanks.
Spring is an IoC container (at least the core of Spring) and is used to wire things using dependency injection. Spring provides additional services like transaction management and seamless integration of various other technologies.
Struts is an action-based presentation framework (but don't use it for a new development).
Struts 2 is an action-based presentation framework, the version 2 of the above (created from a merge of WebWork with Struts).
Hibernate is an object-relational mapping tool, a persistence framework.
JavaServer Faces is component-based presentation framework.
JavaServer Pages is a view technology used by all mentioned presentation framework for the view.
Tapestry is another component-based presentation framework.
So, to summarize:
Struts 2, JSF, Tapestry (and Wicket, Spring MVC, Stripes) are presentation frameworks. If you use one of them, you don't use another.
Hibernate is a persistence framework and is used to persist Java objects in a relational database.
Spring can be used to wire all this together and to provide declarative transaction management.
I don't want to make things more confusing but note that Java EE 6 provides modern, standardized and very nice equivalent of the above frameworks: JSF 2.0 and Facelets for the presentation, JPA 2.0 for the persistence, Dependency Injection, etc. For a new development, this is IMO a serious option, Java EE 6 is a great stack.
See also
Choosing a Java Web Framework now?
Java - JDBC alternatives
JEE6 vs. Spring 3 stack
What to learn for making Java web applications in Java EE 6?
Generally...
Hibernate is used for handling database operations. There is a rich set of database utility functionality, which reduces your number of lines of code. Especially you have to read #Annotation of hibernate. It is an ORM framework and persistence layer.
Spring provides a rich set of the Injection based working mechanism. Currently, Spring is well-known. You have to also read about Spring AOP. There is a bridge between Struts and Hibernate. Mainly Spring provides this kind of utility.
Struts2 provides action based programming. There are a rich set of Struts tags. Struts prove action based programming so you have to maintain all the relevant control of your view.
In Addition, Tapestry is a different framework for Java. In which you have to handle only .tml (template file). You have to create two main files for any class. One is JAVA class and another one is its template. Both names are same. Tapestry automatically calls related classes.
You can see the overview and ranking for yourself here. Hibernate is an ORM, so you can use either struts+Hiberante or spring+hibernate to build a web app. Different web frameworks and many are alternatives to each other.
Spring is an application framework which deals with IOC (Inversion of Control).
Struts 2 is a web application MVC framework which deals with actions.
Hibernate is an ORM (Object-Relational Mapping) that deals with persistent data.
In short,
Struts is for Front-end development of website
Hibernate is for back-end development of website
Spring is for full stack development of website in which
Spring MVC(Model-View-Controller) is for Front-end.
ORM, JDBC for Data Access / Integration(backend). etc
In hibernate you need not bother about how to create table in SQL and you need not to remember connection ,prepared statement like that data is persisted in a database. So, basically it makes a developer's life easy.
Spring is a light weight and open source framework created by Rod Johnson in 2003. Spring is a complete and a modular framework, Spring framework can be used for all layer implementations for a real time application or spring can be used for the development of particular layer of a real time application.
Struts is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model–view–controller (MVC) architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in May, 2000.
Listed below is the comparison chart of difference between Spring and Strut Framework
Tapestry pages and components are simple POJO's(Plain Old Java Object) consisting of getters and setters for easy access to Java language features.
Difference between Spring, Struts and Hibernate are following:
Spring is an Application Framework but Struts and hibernate is not.
Spring and Hibernate are Light weighted but Struts 2 is not.
Spring and Hibernate has layered architecture but Struts 2 doesn't.
Spring and Hibernate support loose coupling but Struts 2 doesn't.
Struts 2 and Hibernate have tag library but Spring doesn't.
Spring and Hibernate have easy integration with ORM technologies but Struts doesn't.
Struts 2 has easy integration with client-side technologies but Spring and Hibernate don't have.

Categories

Resources