This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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?
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.
Customer surveys are for companies who didn't pay proper attention to begin with.