Have a backing bean in request scope; need to access parameters sent to it

I have a request scope backing bean in my app, 'projectBean'. This has a property called 'id'.
/** in request scope in faces-config.xml */
projectBean {
    id               // set by the param from the previous page
    downloadAction() // activated by commandlink, depends on id
}There is another backing bean in session scope called 'projectListingBean', which has a dataTable that lists a bunch of projectBeans. In this 'projectListingBean', I can click on any row. That row, when clicked initializes a 'id' parameter, which is then passed to the new 'projectBean'. 'projectBean' then initializes itself based on the id.
In the jsp page backed by 'projectBean', I also have a link to download something specific to that 'projectBean'. Naturally enough, I have a commandlink with actionBinding to a method in my 'projectBean', downloadXXXAction().
The problem arises because the downloadXXX() method relies on a 'id'. Remember, this id was orinigally set 2 requests back from the datatable. Since the page backed by 'projectBean' is in request scope, the id is lost, and my method call doesn't work. I tried changing the scope of 'projectBean' to session, but JSF complains that I already setting the 'id' property as a param, I can't set the whole managed bean to something 'higher' like session.
Of course, the ideal fix to this probelm would be the ability to have beans in page scope, but what other ways (hacks??) are there to get around this?

Hi, I'm posting some code snippets if it helps with understanding the problem.
faces-config.xml:
<!-- PROJECTLISTINGBEAN -->
<managed-bean>
     <managed-bean-name>projectListingBean</managed-bean-name>
     <managed-bean-scope>session</managed-bean-scope>
     <managed-property>
          <property-name>projectBeans</property-name>
          <property-class>java.util.List</property-class>
          <list-entries>
               <value-class>
                    com.sun.sleuth.omcmweb.view.bean.ProjectBean
               </value-class>
          </list-entries>
     </managed-property>
</managed-bean>
<!-- PROJECTBEAN -->
<managed-bean>
     <managed-bean-name>projectBean</managed-bean-name>
     <managed-bean-class>
     </managed-bean-class>
     <managed-bean-scope>request</managed-bean-scope>
     <managed-property>
          <property-name>projectId</property-name>
          <property-class>java.lang.String</property-class>
          <value>#{param.projectId}</value>
     </managed-property>
</managed-bean>projectlsting.jsp (page backed by projectListingBean)
<h:dataTable value="#{projectListingBean.projectBeans}"
     var="projectBean" ...>
     <h:column>
          <f:facet name="header">
          </f:facet>
          <h:commandLink action="#{projectListingBean.viewProjectSUmmary}">
               <h:outputText value="#{projectBean.projectId}" />
               <f:param name="projectId" value="#{projectBean.projectId}" />
          </h:commandLink>
     </h:column>
</h:dataTable>projectsummary.jsp (page backed by request scoped projectBean)
<h:commandLink action="#{projectBean.assessmentAction}" value="..." />
...Flow:
projectlisting.jsp (projectListingBean - session) -param id passed->
projectsummary.jsp (projectBean - request) -commandLink clicked and id lost-->
projectSummary.jsp (projectBean - request)

Similar Messages

  • How to decide when to keep backing bean in request and session.Pros/cons

    How to decide when to keep backing bean in request and session.Pros/cons

    Depends on where the bean data must be available. Start with request scope. If you need the data in session scope, then think twice about impacts (memory usage, multiple browser tabs, etc) unless the data is obviously targeted on the session scope (loggedin user, user settings, dropdown data, etc).

  • Communicating between beans in request scope

    I have list.jsp that has a table of items with a link to edit each item like so
    <h:dataTable value="#{list.model}" var="curItem">
        <h:commandLink actionListener="#{item.doActionEdit}" action="edit">
          <h:outputText value="#{curItem.id}"/>
          <f:param name="id" value="#{curItem.id}"/>
        </h:commandLink>
    </h:dataTable>edit is map to item.jsp
    when i click on the link the item bean gets called and doActionEdit sets up the id and fetches data from db but then the bean gets recreated (from scratch and all data is lots id is unset) and it loads item.jsp with and empty bean.
    This only happens when item bean is in request scope, however when it is in session scope it works fine, which brings the question; how can I pass objects to a bean that is in the request scope?
    I have tries to map id of item in faces-config.xml with #{param.id} which works fine if id is passed but fails with a npe when item.jsp loads without id (say I want to create a new item.)
    Please advise me what is the best approach to communicate between beans in request scope, so it will work with and without id being passed.

    here is doActionEdit, basicly it gets the id param and then calls setId which tries to load data from db if id is >0 if that fails or id is <=0 it creates new data object instead.
    when the item bean is in session scope the constructor is called once but if the scope is request it is called twice (first time doActionEdit is called after constructor but the 2nd time only constructor is called and the itemData is empty.
         public void doActionEdit(final ActionEvent event) {
                    int id = 0;
              try {
                   id = Integer.parseInt(FacesUtil.getParameter("id"));
              } catch (Exception e) {
                   e.printStackTrace();
              setId(id);
    private ItemData data = null;
         public void setId(final int id) {
              if (id > 0) {
                   data = DB.getItemData(id); //load data from db
                   if (data == null) {
                        data=new Data();
              else {          
                   data=new Data();
         public Item() {
              data=new Data();
              System.out.println("Loading Item class");
         }

  • Getting bean from request scope

    Hi,
    I am new to JSF and unfortunately I am running into a problem that I am not entirely sure about. I look in other forums and what I am doing looks right but I am not getting the desired result.
    In my faces-config.xml file I have a managed bean defined as follows:
    <managed-bean>
        <managed-bean-name>LogIn</managed-bean-name>
        <managed-bean-class>lex.cac.tables.RefUsers</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>I then have a log on page with a form which contains a user name and password field. The tags are defined as
    <h:inputText immediate="false" value="#{LogIn.username}" /> (for username) and
    <h:inputSecret immediate="false" required="true"
                                   value="#{LogIn.password}" /> (for password)
    When I submit the form the web app navigates to a jsp page which attempts to do validation against a database.
    The first step though is retrieving the object which is suppose to be in request scope.
    I attempt the following but I get back null which causes a NullPointerException. Why can't if find the bean?
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    Map params         = ec.getRequestParameterMap();
    params.get("LogIn");  //null is returned hereWhat am i doing wrong? Can someone please help.
    Thanks in advance,
    Alex.

    Something like that:
    FacesContext fc = FacesContext.getCurrentInstance();
    RefUsers LogIn = (RefUsers)fc.getApplication().createValueBinding("#{LogIn}").getValue(fc);
    String username = LogIn.getUsername();
    String password = LogIn.getPassword();

  • Creation of a Managed Bean in Request Scope?

    Is there an easy way to create an instance of a managed bean (configured in faces-config.xml) that was configured to be in the Request scope?
    If a JSP refers to it by id, then it will be there.
    However, when the JSP does not refer to it, it will not be in the request. I find I need to generate it anyway to use it from within another Managed Bean. I can extract out the faces-config information from the application map (available from FacesContext) and build it manually -- but this ties me to a particular JSF implementation (and probably version, too).
    Is there a more standardized way to do this?
    Thanks,
    ken

    BTW -- I mean to do this from within Java code (not jsp), and the page being rendered does not have a direct reference to the request-scoped managed bean via value binding.

  • Shoul I have my backing beans extend my domain objects?

    Hi,
    In our JSF application, most of our backing beans have the same properties that a corresponding domain object.
    In order to have a clear separation between layers, we have a set of view objects and a separate set of domain objects. Once we populate the backing bean, we copy the value of properties to the domain object.
    Since all the properties of my domain object are duplicated in my backing beans, we were wondering if it is a good (or bad) idea to extend (inherit) my backing beans from my domain objects, and pass the backing beans to my persistence and business layers. This will save us some work.
    Thanks a lot for the advice.
    Mauricio L.

    I think I've solved my own issue though I'm not sure if it is the correct way to accomplish the task at hand.
    When the button for login is clicked and the logginButton_action() method is called inside of my login_jsp_backing class I do the following:
    User user = new User();
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("User", user);
    return user.doLogin(this.getInputUsername().getValue().toString(), this.getInputPassword().getValue().toString());
    (The String return of this method in User is a navigation rule I've setup in my faces-config)
    So my new question is that "Is this best practice?" or should I be doing it differently?
    Message was edited by:
    Steve Carlson

  • Hi, I have an issue with a program that needs Windows Access for, it to run, any Ideas on how to make it work, the program I need to run is sbem (a building calculation software)

    Hi
    I have a mac book pro, I need to run a software package that requires Windows Access for it to work
    The software is SBEM (A building calculation software)
    Any ideas
    Many Thanks

    Direct you to the proper forum for MacBook :
    MacBook Series Forumshttps://discussions.apple.com/community/notebooks?view=discussions
    Mac OS X Forums
    https://discussions.apple.com/community/mac_os?view=discussions 
    http://www.apple.com/support/macbookpro
    Mac 101: Using Windows on your Mac via Boot Camp
    https://support.apple.com/kb/HT1461
    Helpful Apple Support Resources (Forum Overview)
    Boot Camp Support 
    Boot Camp Manuals
    Community
    https://discussions.apple.com/community/windows_software/boot_camp
    Boot Camp 4.0, OS X Lion: Frequently asked question
    http://support.apple.com/kb/HT4818

  • I do not have a Firefox Button. Which I need to access options to solve a problem.

    I want to solve a problem with my bookmarks. The suggestion said to click the Firefox button at the top of the page. I do not have a Firefox button.
    Running WindowsXP Home.

    The new interface is only default on Windows Vista and Windows 7. To get it on Windows XP you need to hide the menu bar. To do that in the View menu select Toolbars, then click on the "Menu Bar" entry.
    If you need access to the menus you can press either Alt or F10 to temporarily display them.

  • Problem with Commit button When Backing bean is in Request Scope...

    HI Everybody,
    I have a Backing Bean in request scope having over 1000 lines of code, And in my JSPX page I have a table binding with a view object and At run time when user select the row in table and click the edit button so user will be able to edit that selected row in the same table at run time.. but the problem is : when the user enters some data in the Editable inputTexts and then clicks save(Commit), then the save button doesn't work..but when i delete any selected row and then press save then it is working fine..
    And to test it in Session scope i made another sample page where every thing is working very fine..
    Now i want to know What is the difference between Session scope and request scope bean...
    And is there any solution to Save editable input text in Request scope?.
    Also want to know that is it safe to set the scope of my main bean class to session scope without effecting the current running functionality? which is having over 1000 lines of code and lot of component has been placed...
    Please help me to resolve this problem...
    Thanks in Advance to all of you
    Fizzz..

    Hi Frank...
    In my code i used almost same logic as Andrejus Baranovskis has explained in his Editable Table example...
    You can refer that example to see what problem I'm facing...
    http://andrejusb.blogspot.com/2007/04/create-edit-and-delete-operations-in.html
    The Bean Scope in this Example is Session scope...Save button is working fine...
    But as i Change the bean scope to Request scope then Save button is not working for Edit but it is working for Delete Action very well..
    I want that save button should work also for Edit action in Request Scope..
    Please Make me understand that why it is happened like that..
    and help me to find the solution..
    and Also if you have a better document to Explain the life cycle of Application in Different Bean Scope...So please provide me that Doc to me...
    It would be a great help for me to understand the concept of session...
    Thanks Frank
    Fizzz...

  • Partial page refresh in REQUEST scope

    Hi,
    I was going through the various example of partialTrigger.
    But in I am unable to find the example in where we can use the partialTrigger with having our backing bean into request scope. means Can we do partial page refresh without keeping our backing bean into session scope?
    Can we do partial page refresh across different fragments (different jsf fragment - jsff ) with having the our backing bean in a request scope?
    Is there any way that we can achieve this?
    Please can any one provide some input or help on this?
    Thank you in advance.
    - Kumar

    Hi,
    Can we do partial page refresh without keeping our backing bean into session scope?
    Yes, don't know how you get to this idea that you couldn't. You can use ADFFacesContext.getCurrentInstance().addPartialTarget(component)
    Can we do partial page refresh across different fragments (different jsf fragment - jsff ) with having the our backing bean in a request scope?
    You are posting a JDeveloper 11 question without saying it first. Also note that there is a JDeveloper 11 forum here on OTN. To answer the question, I don't think that you can do this and that instead you would use a region and contextual events to refresh the area
    Frank

  • How to handle Valuechange events, when page bean is in request scope

    Hello balusc and forum mates,
    I want to know is there any good way to handle ValueChangeEvents events, when the page's bean in request scope.
    My problem is, I have a page having more than 1 value change event so How can I maintain page values at backing bean. My bean is request scope, I can't change to session scope.
    Please I really need it.

    Hi Frank...
    In my code i used almost same logic as Andrejus Baranovskis has explained in his Editable Table example...
    You can refer that example to see what problem I'm facing...
    http://andrejusb.blogspot.com/2007/04/create-edit-and-delete-operations-in.html
    The Bean Scope in this Example is Session scope...Save button is working fine...
    But as i Change the bean scope to Request scope then Save button is not working for Edit but it is working for Delete Action very well..
    I want that save button should work also for Edit action in Request Scope..
    Please Make me understand that why it is happened like that..
    and help me to find the solution..
    and Also if you have a better document to Explain the life cycle of Application in Different Bean Scope...So please provide me that Doc to me...
    It would be a great help for me to understand the concept of session...
    Thanks Frank
    Fizzz...

  • Avoiding request scope bean clashes for task flow calls

    Hi,
    I have two task flows, Tf1 calls Tf2 using a task flow call activity. The structures of the task flows are as follows:
    Tf1
      Managed Bean: TfBean, request scope
        class Tf1Bean
          has property goTf2Button
      View: View1
        Button bound to #{TfBean.goTf2Button}
          Action -> task flow call to Tf2
    Tf2
      Managed Bean: TfBean, request scope
        class Tf2Bean
          has property testButton
      View: View2
        Button bound to #{TfBean.testButton}
    As you can see both have a request scope bean called TfBean but these are different classes in each. The bean classes have different properties for binding the components on the two pages.
    When I click the button in View1 to navigate I get an error telling me that class Tf1Bean does not have the property testButton. Clearly Tf2Bean is not being instantiated as TfBean already exists for the request.
    I'm guessing this is expected behaviour and it seems logical.
    My question however is what would be good standards or practices to avoid this?
    One way would be a naming convention, however what if I am consuming Tf2 from a library? In this case it would ideally work as a black box and I should not be concerned about it's implementation, specifically names chosen for internal managed beans. Even if it was not a problem initially, the developer of the task flow could add or change the name of a request scope bean introducing a conflict at a later stage.
    Thanks,
    Kevin

    Hi Frank,
    Good to meet you at UKOUG Tech13 yesterday. I changed my test case from request scope to backing bean scope. Unfortunately I still get the same error:
    <RichExceptionHandler> <_logUnhandledException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase RENDER_RESPONSE 6
    javax.faces.FacesException: javax.el.PropertyNotFoundException: The class 'yyy.view.Tf1Bean' does not have the property 'testButton'.
      at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1900)
      at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:446)
      at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:222)
      at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:506)
      at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:744)
      at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1311)
      at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.doStartTag(UIXComponentELTag.java:67)
      at oracle.adfinternal.view.faces.unified.taglib.nav.UnifiedCommandButtonTag.doStartTag(UnifiedCommandButtonTag.java:51)
    ...etc.
    What I think is happening, please correct me if I'm wrong...
    Running Tf1, page View1 is displayed.
    Clicking the button on View1 initiates a request and an instance of Tf1Bean is instantiated for the managed bean named TfBean.
    During the request navigation occurs to Tf2 and hence page View2.
    View2 needs a property in TfBean called testButton.
    There is already a managed bean instantiated for this request called TfBean, however this is of class Tf1Bean and does not have the property.
    I have a simple workspace showing this if you want me to send it to you. I am using 11.1.2.4 by the way.
    Thanks,
    Kevin

  • Create a report in a popup (validation needed in back bean before popup)

    Hi all,
    I am very new to JDev and ADF, I am struggling to generate a report in a popup through the back bean, some validation is needed in the back bean before the popup. When creating the popup window, the url of the popup will be the URL of a servlet I searched the forum and found 2 approaches:
    http://thepeninsulasedge.com/frank_nimphius/2007/09/11/adf-faces-showing-reports/
    can af:showPopupBehavior work together with action- or launchListener? (approach by Julian Stephen)
    But I have a few questions for these approaches:
    for first approach:
    is “documentURL” in the commandButton_action() the url for the my report servlet,
    another thing is that, in this commandButton_action(), it said: return "dialog:open"; But I couldn’t find anywhere in the content that shows dialog, open are component ids? Or I am misunderstood it?
    for the second approach:
    where is the url for my report servlet put? Is it in the "hints" in the function “popup.show(hints)”?
    I can try the second approach first, but for the first approach I really want to know what is the "return dialogLopen" about?
    If there are any other means, please let me know!
    Your help is highly appreciated!
    Shawn

    My bad, in the first approach, "dialog:open" is the action string not component ids.

  • Using a backing bean in JDeveloper to assign bean class variables

    I am using JDeveloper 10 to make a jsp page that is a form full of inputs and buttons. JDeveloper then creates the setters and getters for you for the ids of the various inputs and buttons. I also have used JDeveloper to create a backing bean.
    The idea of this is to have the backing bean read in parameter(s) from an http source/link(when the form is loaded or instantiated) and assign those parameter(s) to one of the bean class local variables.
    The reason i want to do this is, is that when the form is loaded the first thing it will do is open up an available database(in the bean class constructor), then in the constructor call a function to do a database query that will return a result set that will then be used to fill up the form.
    That variable that is assigned by the backing bean will be the value of a unique database identifier for doing the sql query so that is why it is important that i get this value as the form loads.
    So simply i need to find out from someone how to do this. i am totally new to doing any jsp development or using managed beans and i have gotten far enough to launch the form, retrieve and write to the database using sql queries and all the rest.
    I just dont know enough about managed beans to make a decision on things like making the bean have a session scope. do i need request scope? if i change to request scope how do i make sure the database isn't being called every time the page changes or is refreshed?(when i had it as request scope the constructor was being called every time the page was reloaded and that isnt effecient at all, especially with multiple users). can you define more than one managed bean in one faces config file? do i have to manually change something in the jsp file to make sure things run smoothly?
    Just maybe things are easier than i see them to be and my only problem is that i just dont understand what i am doing. here is what my backing bean looks like now with just basic session scope.
    An example of course would be something like: http://host:port/context-root/faces/register.jsp?12345 - where 12345 would be the value that i would like to assign to a local variable in my bean class that can then be used for filtering out information via a query then filling up the form, all this happening at instantiation.
    <?xml version="1.0" encoding="windows-1252"?>
    <!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config xmlns="http://java.sun.com/JSF/Configuration">
    <managed-bean>
    <managed-bean-name>beanpackage</managed-bean-name>
    <managed-bean-class>beanpackage.beanclass</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <!--oracle-jdev-comment:managed-bean-jsp-link:1register.jsp-->
    </managed-bean>
    </faces-config>
    This is what i have now, i've tried tons of stuff on the web like assigned value parameters but just am stuck on exactly what to do as nothing has seemed to work. Any help would be appreciated. Thanks in advance!

    Hi,
    don't think you will get a readily programmed solution to this (though I wish you luck). Here's how I would approach the managed bean issue
    - One managed bean that you configure from a java.util.HashMap. This bean should be in requestScope (should be okay here). Say the bean is called "formFields", then adding data to it can be done with the following EL #{formBean['attribute_name']}. You need to add this as the value Expression of the inputText field you create dynamically. The filed will then read and write to the HashMap
    - Create a managed bean in session scope to handle the database interaction. Put this into session scope (e.g. "database")
    - Create a managed bean that holds the action listener that handles the update, insert and delete actions (e.g. logic handler). This bean has a JSF reference to the root component in the page (or the form layout component to add the fields to)
    The "database" bean is referenced from the logic handler managed bean using the #{database} expression, which you resolve using a ValueBinding (ExpressionBinding in JSF 1.2). Or, you configure the bean as a managed property.
    The logic managed bean also needs to reference the formFields bean (similar to above) to access the contained filed names and attributes. If the filed attributes match column names in the database then you should be all set
    Frank

  • Session backing beans and multiple navigator windows sharing session

    Hi let's suppose i have a web and page1, page2 and page3 that should share the backingbean. Normal navigation goes from page 1 to page 2 to page 3.
    I do not want a backing bean per page because i need to share data between my pages. The immediate solution is to put this bean in session context and use it in each page. But this has severe drawbacks:
    - The backing bean is the same each time I access any page, and I want a new bb to be used each time the user requests for page 1
    - When a user has more than one navigator window sharing session, and on each window he is navigating through pages 1 to 3, there can be a big mess because he is accessing to the same bb from both windows.
    So I would like to find a solution that permit the user to navigate from both windows as if the windows had its own session.
    Any hint?
    Thnx

    I have a similar problem as described .
    I hava one window with enterable fields and when you click on a button it opens another window .Both forms are backed by the same bean .since both forms are nearly the same .
    The bean is a managed bean in request scope .
    when I fill in the first window with values and click on the link it opens the second but the first windows elements and now empty .
    Even though it is in Request scope when the second window is being loaded the bean is re-initialized . I would expect a new intance of this bean to be created for the second window .
    This is how I am calling the second window .
    <h:commandButton id="newRequestItem" action="#{requestItem.createNewRequestItem}" rendered="#{createActivationRequest.displayCreateLinks}" onclick="openNewPage('NewRequestItem.jsp');"
    image="images/show_all.gif" title="new request">
    <h:outputText value="new request" styleClass="toolbar-command"></h:outputText>
    </h:commandButton>
    function openNewPage(url)
         aqcbwin= window.open(url, "newRequestItem","toolbar=no, scrollbars=1");
    aqcbwin.moveTo(50, 50);
    target="_new";
    //target="_blank";
    aqcbwin.focus();
    any ideas to what is wrong and how I can correct this .
    Thanks for your help .
    Mark

Maybe you are looking for

  • How can I delete ALL of the offline files in the catalog?

    I have Photoshop Elements 10, and a catalog with over 60,000 items in it. About 10,000 of those items were on an external drive ("E: Drive"). The E drive crashed, and all of those files are now on a different external drive, the F drive. On the E dri

  • Javabean is not working after adding webutil.olb in form 10g

    I have created a form in which I am using javabean for running marquee and is working well. I have also attached webutil library in that form and it's working well also. But when I am adding webutil.olb in that form marquee stops to work. I have give

  • How to reset the TMP password?

    Hi, to all, this is my first post on this forum. I've got Lenovo ThinkPad Z61m, and got problem with the Client Security Solution. This is the message when I try to configure this program: " The Trusted Platform Module (TPM) on this system has been c

  • Audio lost from Keynote 09 import to iPad

    I thought the recent Keynote for iPad software update was supposed to allow importing audio from Keynote 09 files. I still have no audio with these files on the iPad. Suggestions?

  • FCServer noob, transcription, keywords, timecode and web deployment

    Hi all, My company has a potential job coming up where we will be shooting interviews and b-roll at many various locations around the country. Our client wants that footage to be accessible pretty quickly, in a searchable, web-friendly way. They want