Note that there are some explanatory texts on larger screens.

plurals
  1. POSuggest a design pattern for application using JSF , EJB 3.0
    text
    copied!<p>i have created a demo application Using JSF &amp; EJB 3.0 (Stateless session bean and JPA), my persistence provider is Hibernate 4, and database is Apache Derby.</p> <p>My class flow i.e sequential flow is as follows,</p> <p>ManagedBean calls Stateless Session bean, in this we have a JPA calls,</p> <p>please follow the code, the JSF managed bean StudentMgBean.java,</p> <pre><code>@ManagedBean(name="stMgBean") @ViewScoped public class StudentMgBean implements Serializable{ private static final long serialVersionUID = 109117543434170143L; ........... @EJB private StudentService studentService; ......... @PostConstruct public void init(){ .......... ........ this.totalStudentInDB = studentService.getMaxStudent(); } } </code></pre> <p>My EJB Interface StudentService.java,</p> <pre><code>@Local public interface StudentService { List&lt;StudentVO&gt; fetchStudentListOrderByStudentId(boolean flag); List&lt;StudentVO&gt; fetchStudentListOrderByStudentName(boolean flag); void saveStudentEntity(StudentEntity studentEntity,Integer deptId) throws Exception; List&lt;DeptEntity&gt; fetchAllDept(); List&lt;StudentVO&gt; fetchStudentByDept(Integer deptId); void saveAllStudents(List&lt;StudentVO&gt; students) throws Exception; void deleteAllStudents(List&lt;StudentVO&gt; students) throws Exception; List&lt;StudentVO&gt; fetchStudentListPerPage(Integer minRow,Integer maxRow) throws Exception; Integer getMaxStudent() throws Exception; } </code></pre> <p>My EJB Stateless Session bean StudentServiceBean.java,</p> <pre><code>@Stateless @TransactionManagement(TransactionManagementType.CONTAINER) public class StudentServiceBean implements StudentService{ @PersistenceContext(unitName="forPractise") private EntityManager entityMgr; @Resource private SessionContext sessionContext; @EJB private DeptService deptService; @Override public List&lt;StudentVO&gt; fetchStudentListOrderByStudentId(boolean flag){ ......... } @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void saveStudentEntity(StudentEntity studentEntity,Integer deptId) throws Exception{ ........ } } </code></pre> <p>In the StudentServiceBean, i have injected EntityManager, so i directly do JPA operation in the methods written in this session bean.</p> <p>No my question is can i use any design pattern in this flow, can i go for a separate DAO layer, as i am using EJB 3.0 i don't have to use ServiceLocator pattern, but than any other pattern can i use to seperate Bussiness logic with the JPA call,</p> <p>One more thing, In JSF managed Bean i have properties and its getter setter methods which are mapped to the JSP componenets in EL like this value={stMgBean.studentList}</p> <p>but in the same managed bean i have also have method which will be invocked by action command call from JSF, should those method be written in the seperate Managed bean ?</p> <p>Please suggest a Design pattern which can be used for projects which have JSF 2.0, EJB 3.0 and JPA</p> <p>Waiting for the reply</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload