I read some post hear (specially BalusC post) and googled for the reason (not deep) but i couldn't find why shouldn't use entity bean as a managed bean. what's the reason? (I'm learning from "Pro JSF and HTML5" and in this book, entity bean is used as a managed bean.)
相关问题
- java.lang.NullPointerException at java.io.PrintWri
- h:selectOneMenu in p:dataTable doesn't submit
- PrimeFaces block UI does not work when the compone
- primefaces orderlist not getting updated with the
- JSF2 composite cc.attrs expression does not evalua
相关文章
- How to allow numbers only using f:validateRegex
- JSF 2.0: ajax request when press ENTER
- Formatting a double in JSF
- change rendered attribute from managed bean
- f:convertNumber on Double: ClassCastException
- SeamPhaseListener - Could not start transaction -
- How do I access EJB bean when inside a custom Conv
- Getting value from dynamically created inputText
Separation of concerns.
Normally, enterprise applications are developed and deployed as EARs instead of WARs. A typical EAR project consists of an EJB subproject as "back-end" and a WAR subproject as "front-end". The EJB subproject contains all JPA entities and EJB services. The WAR subproject contains all JSF managed beans and views (and what not closely related to JSF such as converters, validators, phase listeners, etc).
A good EJB subproject may not have any dependency on JSF. This makes it reusable for different front-ends, such as Spring MVC, JAX-RS, Struts2, plain JSP/Servlet or even a desktop oriented Swing application. This also means that no one of your JPA entities and EJB services should have any
javax.faces.*
import/dependency in the class. Having for example aFacesContext
at hands inside a JPA entity or EJB service is alarming as that doesn't necessarily exist in other front-ends.The "Pro JSF and HTML5" concentrates on simple WAR projects. Therein that's "okay" in order to show the possibilities and/or to keep the examples "simple", but that's actually misleading to starters once they grow into developing enterprise applications, the more so if the book doesn't cover the design concern in detail.
See also: