Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7736497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:44:48+00:00 2026-06-01T07:44:48+00:00

i have created a demo application Using JSF & EJB 3.0 (Stateless session bean

  • 0

i have created a demo application Using JSF & EJB 3.0 (Stateless session bean and JPA), my persistence provider is Hibernate 4, and database is Apache Derby.

My class flow i.e sequential flow is as follows,

ManagedBean calls Stateless Session bean, in this we have a JPA calls,

please follow the code,
the JSF managed bean StudentMgBean.java,

@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();
     }
}

My EJB Interface StudentService.java,

@Local
public interface StudentService {
    List<StudentVO> fetchStudentListOrderByStudentId(boolean flag);

    List<StudentVO> fetchStudentListOrderByStudentName(boolean flag);

    void saveStudentEntity(StudentEntity studentEntity,Integer deptId) throws Exception;

    List<DeptEntity> fetchAllDept();

    List<StudentVO> fetchStudentByDept(Integer deptId);

    void saveAllStudents(List<StudentVO> students) throws Exception;

    void deleteAllStudents(List<StudentVO> students) throws Exception;

    List<StudentVO> fetchStudentListPerPage(Integer minRow,Integer maxRow) throws Exception;

    Integer getMaxStudent() throws Exception;
}

My EJB Stateless Session bean StudentServiceBean.java,

@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<StudentVO> fetchStudentListOrderByStudentId(boolean flag){
        .........
    }

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void saveStudentEntity(StudentEntity studentEntity,Integer deptId) throws Exception{
        ........
    }

}

In the StudentServiceBean, i have injected EntityManager, so i directly do JPA operation in the methods written in this session bean.

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,

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}

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 ?

Please suggest a Design pattern which can be used for projects which have JSF 2.0, EJB 3.0 and JPA

Waiting for the reply

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:44:51+00:00Added an answer on June 1, 2026 at 7:44 am

    You can split the JSF layer using the next concepts:

    • Put all the data which are going to be shared between the java side and the view into specific managed beans called “Models”. Now you can manage the scope of the data independently from the scope of the rest of managed beans.
    • Use the command pattern which delegates all the actions which will modified the model to the commands. The commands may invoke the EJB layer, or just update the models without going to the next layer.
    • Keep in the managed beans just the logic that you need to initialise the JSF components in the views or manage their behaviour, a reference to the model, and a reference to a delegator which will provide the command to run.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a small demo application in Java using Spring, that needs to have
I have created WCF client/ server applications using calculator demo as mentioned in http://msdn.microsoft.com/en-us/library/ms734712.aspx
I have created the following demo: http://thedrivepartnership.com/overflow.html The scrolls expand fine in FireFox /
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a C# class file by using a XSD-file as an input.
I have a Win32 C++ Application using a handful of third-Party DLLs that is
I want to call web services in phonegap application. I am using demo code
I've created a basic demo app in Rails 3.2.2 by using rails new demo.
I have created a UIScrollView in a cocos2d application. I am adding sprites dynamically,
In my Django application I have Guest user accounts that are created for all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.