aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes JSF and session beans Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "JSF and session beans" Watch "JSF and session beans" New topic
Author

JSF and session beans

Tomasz Romanowski
Ranch Hand

Joined: May 06, 2009
Posts: 38
Let's suppose my user interface requirements make JSF a good fit for the front-end and business logic complexity, transactional and scalability requirement warrant the use of EJB (session beans and entity). So I write my entities, code business logic in session beans, expose some APIs in session beans to JSF etc.
Now suppose that in certain cases I find it beneficial and much easier in my JSF Web module to work with the entities directly (i.e. for certain queries) and not go through EJB session beans any time time I want to access the database. Is that an acceptable, good architectural solution? Or should the web module use entities only if the whole app is enclosed in the web module without any session beans?

On another note, all JSF tutorials I've come across use entities directly without a separate EJB application module. Can anyone refer me to an example whereby JSF talks to EJB session beans? I'm assuming you'd still have the JSF controllers which would talk to EJB session beans rather than local JPA controllers, right?
Shivaji Byrapaneni
Greenhorn

Joined: Oct 20, 2008
Posts: 22
Using entities in the JSF managed bean can be done as entities are similar to Transfer Objects (TO) once they are detached form teh EntityManager persistent context. So it wont harm at any cost.

But one pinching thing about your query is using the entity manager in the JSF managed bean itself to persist or update the entities from the managed bean itself. Which is a wrong sign as Manged beans are not
1) Thread safe
2) Cant manage transactions
3) Not as secured as EJB
4) etc..

soooo it would be bad approach to use the entity manager to persist the entites or act on entities in the managed bean itself.


Thanks & Regards,<br />Shivaji Byrapaneni.
Tomasz Romanowski
Ranch Hand

Joined: May 06, 2009
Posts: 38
Shivaji Byrapaneni wrote:Using entities in the JSF managed bean can be done as entities are similar to Transfer Objects (TO) once they are detached form teh EntityManager persistent context. So it wont harm at any cost.


Perhaps I didn't make it clear but I meant to use JSF managed beans only to access the database for read-only purposes. From what you're saying it should be ok. However, I would imagine I'd still need Entity Manager to access the data. Why would I want to do without Entity Manager?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF and session beans
 
Similar Threads
Accessing FacesContext from a Session Attribute Listener
EJB 3 Entities:clarification
SCEA-2 if using framework like seam then still have to use J2EE design pattrems ?
Facades, Entity Beans and DAOs
JEE5 Application Architecture Best Practice.