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 6922337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:23:35+00:00 2026-05-27T10:23:35+00:00

I have a web app using JSF2 with JPA Entities, Stateless ejb session beans

  • 0

I have a web app using JSF2 with JPA Entities, Stateless ejb session beans as my facade/ejb objects, and managed beans (request and view scoped) as controllers exposing business methods, managed controllers are pulling data from the injected stateless session beans.

but i am confused how to navigate and retain data accross views in my controllers in this environment, for example:

I have a jsf2 view page (departmentView.xhtml) that displays a list of Department objects and each row has an edit item. Clicking edit I want to load a new page and display
a list or Employee’s for that department on the new page, so i invoke the Employee controller passing it the selected Department

action="#{employeeController.getEmployeeListForADepartment(ithDepartment)}" 

here is a snippet of my departmentView.xhtml

    <h:dataTable id="table" value="#{departmentController.departmentList}" 
            var="ithDepartment">
...
<h:column>              
<h:commandLink id="editId" value="Edit"
action="#{employeeController.getEmployeeListForADepartment(ithDepartment)}" />
</h:column>

and my employeeController is defined as

ManagedBean(name = "employeeController")
@ViewScoped
public class EmployeeController implements Serializable {
   ...
private List<Employee> employeeList = new ArrayList<Employee>();
   ...      

@EJB
private com.ejb.session.EmployeeFacade ejbEmployeeFacade;    
   ...

public List<Employee> getEmployeeListForADepartment(Department dept) 
{
    if(employeeList==null || employeeList.isEmpty())
          employeeList = ejbEmployeeFacade.findEmployeesByDepartment(dept);  

// now i want to navigate to the employee view showing these employees for the
// selected department.
// but this navigation below triggers creating a new EmployeeController 
// and i lose my employeeList 
    return "employeeView";
}

i really want to avoid using jsf session scope, and believe there is a way to do this, just not reading about it in any of my jsf/ejb books.

thinking outloud, maybe don’t have EmployeeController.getEmployeeListForADepartment(..) do a lookup, just create a parameter from the department id and pass that along via return "employeeView?departmentId=X"; and have constructor then do a lookup if the id is present?

can somehelp me with the proper way to implement this in EJB/JSF2 environment

thanks

  • 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-05-27T10:23:36+00:00Added an answer on May 27, 2026 at 10:23 am

    Use a simple GET <h:link> in the source view to pass the department ID and a <f:viewParam> in the target view to convert and set the department.

    E.g.

    <h:link id="editId" value="Edit" outcome="employeeView">
        <f:param name="departmentId" value="#{ithDepartment.id}" />
    </h:link>
    

    with

    <f:metadata>
        <f:viewParam name="id" value="#{editDepartmentBean.department}"
            converter="#{departmentConverter}" converterMessage="Bad request. Unknown department."
            required="true" requiredMessage="Bad request. Please use a link from within the system." />
    </f:metadata>
    

    and

    @ManagedBean
    @ViewScoped
    public class EditDepartmentBean {
    
        private Department department;
    
        // ...
    }
    

    See also:

    • Communication in JSF 2.0 – Processing GET request parameters
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a web app using session state management as per the instructions
I have a JSF 2.1 (MyFaces) app running using several Session Beans (All the
I have been developing my web-app using JPA 2.0 implementation EclipseLink 2.2.0. I finally
I have a web app using forms authentication and I have restricted a folder
I have developed a web app using a webservice. Everything works fine in the
I am working on a web app using C# and asp.net I have been
I am developing a web app using servlets and jsps. I have a question
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
I have a web app which connects to a server using a TCP connection

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.