• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Best Practices for JSF-Spring-Hibernate

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have developed simple CRUD application using JSF, Facelets, Ajax4JSF, Spring & Hibernate based on Appfuse/Equinox framework. After making the application to work successfully i am wondering whether i have used the best practices. Here is an example

" Is it recommended to instantiate Model object in Backing bean"

To elaborate the statement .........

I have the following

UserForm is a JSF managed bean,
User is a hibernate mapped POJO, and
UserManager is manager class in Spring
------------------------
UserForm.java (Backing Bean)
----------------------------
public class UserForm {
.........
.........
public User user = new User();
public UserManager mgr;
.............
.............
// Getter & Setter methods for user & mgr
....................
....................
//Persistence
public String save() {
mgr.saveUser(getUser());
addMessage("user.saved", getUser().getFullName());

return "success";
}
}

I undertand the purpose of having UserManager defined in backing bean but wondering why do we need to have Model (i.e. User) defined in backing bean . Is this a best practice?


Is it recommended to populate model object with data in the backing bean and then call for business methods like mgr.saveUser(getUser()



I am wondering about perfomance issues i.e. making DB calls from backing bean getters or setters. DB calls can mean a performance hit, and JSF will call the getters and setters multiple times per page request (which means you'll be doing multiple DB calls).



Regards

Bansi
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recommend that you check out JBoss Seam for JSF development. It uses Facelets, ajax4Jsf, JPA (Hibernate-based), etc. so you wouldn't need to do too much additional learning. Appfuse-JSF, IMO, is not a good JSF example that you should be looking at. It's overcomplicated, and it uses Spring (which is a good framework on its own) but it doesn't integrate well with JSF handling of stateful components. Check it out.
 
You showed up just in time for the waffles! And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic