Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

managing beans based on URL query parameters

843842Nov 7 2003 — edited Apr 19 2008

I was just reading this thread with interest, but it didn't come to the conclusion that I need.

http://forum.java.sun.com/thread.jsp?forum=427&thread=441432

In that thread, there were two screens: a table of links to employees and an "edit employee" page. The solution was to use the command_action on the list create an "employee data" bean, which could then be edited on the "edit employee" page.

My problem is that I need to create some session beans based on query parameters in the URL. Using the example above, I'd have something like: http://localhost/app/editEmployee?empNo=38

Why? Because the user can bookmark the edit employee page, have two
browser windows open (which would require two seperate employee data beans), etc... and we need to handle that. It looks like
that means I can't use the solution in the above thread.

My current thought is to create a managed-bean with request scope and have it create the EmployeeData bean.

Another idea is to somehow initialize the bean with managed-properties
<managed-bean>
    <managed-bean-name>EmpBean</managed-bean-name>
    <managed-bean-class>com.mycompany.EmpBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
        <property-name>employeeID</property-name>
        <value-ref>queryParamBean</value-ref>
    </managed-property>
</managed-bean>

<!-- 
  just returns FacesContext.getCurrentInstance().getServletRequest().getParameter("id")
-->
<managed-bean>
    <managed-bean-name>queryParamBean</managed-bean-name>
    <managed-bean-class>com.mycompany.QueryParamBean</managed-bean-class>
    <managed-bean-scope>none</managed-bean-scope>
but that seems kinda hacky. Any other ideas?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2008
Added on Nov 7 2003
10 comments
566 views