Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

To Develop apllication using JSF and Hibernate  RSS feed

 
Patel Mahesh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to develop web application using jsf and hibernate .i m confused about the design pattern to follow .how to implement the mvc pattern in this?
while creating application with Jsp and hibernate my hibernate pojo file was the Model ,Servelet the Container and Jsp the Views.

Please Guide me someone,thanks for the help.


Is Spring Required in jsf anf hibernate.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patel Mahesh wrote:
while creating application with Jsp and hibernate my hibernate pojo file was the Model ,Servelet the Container and Jsp the Views.
.

Did you mean Servlet the controller? In JSF the FacesServlet is your controller so you don't need to write that; your M is the business services, entities and their DAOs and the V are your xhtml pages and your other JSF specific classes. The view part itself also implements MVC but that is another story.

Patel Mahesh wrote:
Is Spring Required in jsf anf hibernate.
It's not required. It can be used if want to use spring DI but you can also use other DI apis like CDI.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MVC covers only the interactions between Models and Views as facilitated by Controllers. Pure MVC has no business or database logic in it. Which is OK if all you want to do is impress people with your pretty GUI, but not for practical work.

In JSF, the Model is actually a dual-purpose object rather than being a pure MVC Model. It is both the MVC Model and it is the primary point of entry into the Business layer. This entry point is provided primarily by the action method (which a lot of people wrongly mistake for a Controller Method. Controller methods only synchronize Model and View, and as Mr. Armitage has indicated, in JSF, that function is performed by the FacesServlet (with sub-controllers in the pre-supplied tag components).

The architecture of my most common industrial-scale webapps has business and/or persistence services injected as managed properties into the backing beans (Models). The action methods then use these services as necessary.

What I actually have is a higher-level business persistence layer (Service) and a lower-level raw persistence layer (DAO), where the DAOs are injected (via Spring) into the Services. The DAOs do essentially table-at-a-time persistence, and include the CRUD and finder atomics. The Services handle the interactions between multiple persistent objects that are all committed under a single transaction. In my case, data model objects are detached from the ORM above since I feel that keeping ORM objects attached across JSF phases is a good way to get into trouble.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!