Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to JSF : Interaction between JSF and EJB's

 
Arjun Marayil
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to JSF.

I am writing a small program for User Management. I have an entity bean and database table for user. I have also written a session bean "UserManager". This session bean has methods for create/modify and delete user operations.

my question is:

If I use JSF, I need to use a java bean and set the values from the JSF to this java bean, then call the EJB from a method in this java bean. Right?
How will I do the mapping from java beans to Entity beans?

Please help.

Thanks.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In theory, you could use an EJB directly as a JSF backing bean, but in practice it's not very realistic. You do better to let an ordinary backing bean be the go-between.

An industrial-grade application would put the display interaction in the backing bean, optionally have it invoke a business-layer bean for app-specific business logic, have that bean invoke a DAO or data service bean (which could be a session EJB), and it would manage the storage and retrieval of entity EJBs. Which may seem a bit much, but in major apps, having a few well-defined layers of simple functions beats lumping things together in one big ugly do-everything object.

I use the JPA and the Spring framework for my persistence-layer functionality and it works quite well for me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic