Submit: new or existing backing bean?

I have a page that has a backing bean and a Save button:
<h:commandButton value="Save"
          action="#{objInstancePage.save}"          
          id="saveButton" />
When it is clicked the save() method is called on my objInstancePage bean. This is almost what I expect, but it seems like JSF is creating a new ObjInstancePage bean and calling the save() method on the new bean. #{objInstancePage } was referenced several other places on the page before the save button. The new bean doesn't have data that I have put into the bean other places on the page. So the data I want to save isn't there on the server when save() is called.
Is this a misunderstanding on my part? I thought JSF would call save() using the same bean instance that is used other places on the page, and not create a new bean. Thanks.

Not actually. A request scoped bean has a lifetime of one request. This lifetime starts when the client invokes a request (either GET by a link or POST by a form) and ends when the response is been completed to the client. So once the webpage is finished loading at the client, the request scoped bean is garbaged. When you submit a form on this page to the server, a new request scoped bean will be created, with all properties set to default. A session scoped bean has a longer lifetime and will only be garbaged when the session is invalidated. An application scoped bean has the same lifetime as the servletcontext and is been garbaged when you restarts the webapplication on the server or shutdown the server.

Similar Messages

  • Display values on new window from backing bean HashMap

    Hi,
    I need to open a new window when user clicks on some link from the current page. New window will display few values which are set once the link is clicked.
    I have created a bounded task flow with a jspx page added into the task flow. This jspx page contains a jsff page. While clicking on the link, I have called backing bean method which will create and set a HashMap containing key-value set which is used to display on new window.
    New window is created by javascript. And I am not able to get HashMap values which are set by bakingbean method.
    Is there anyway to solve this?
    Code:-
    Backing Bean method to open new window
    private void launchWindow () {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    // Taskflow parameters map
    Map <String, Object> params = new HashMap <String, Object> ();
    // Get taskflow URL to be opened in new window.
    String taskflowURL = ControllerContext.getInstance ().getTaskFlowURL (false, new TaskFlowId (
    AppsConstants.DESCRIPTION_TASKFLOW_DOCUMENT,
    AppsConstants.DESCRIPTION_TASKFLOW_ID), params);
    taskflowURL = taskflowURL.replaceAll("%2F", "/");
    ExtendedRenderKitService erks = Service.getRenderKitService (FacesContext.getCurrentInstance (), ExtendedRenderKitService.class);
    String jsScriptWindowOpne = "window.open(\"" + taskflowURL + "\", \"" + resourceBundleMapper.getString (AppsConstants.LBL_NOTI_DESC_NEW_WINDOW_TITLE) + "\");";
    try {
    erks.addScript (FacesContext.getCurrentInstance(), jsScriptWindowOpne);
    } catch (Exception e) {
    logger.log (Level.SEVERE, "Exception while adding javascript to open a new window in ExtendedRenderKitService object. " + e);
    New window jsff page
    <af:outputText value="#{backingBeanScope.notification.notificationDescriptionMap}" />
    Output
    I want to get values from this HashMap, to test the size/content of this Map, I have printed this Map.

    Hi,
    Yes its possible..
    A simple google search gave me this Result.
    Betw:
    you can also open taskflow as popup in your page(inline popup) instead of opening the taskflow in other browser window.
    53-taskflow-in-popup-169196.pdf
    Regards,
    Santosh.
    Edited by: Santosh Vaza on May 11, 2011 2:11 PM

  • How can I incorporate new backing beans into a Webcenter Spaces Server?

    I am using the WebCenterSpaces application in Customization Developer Role to make changes to some taskflows for a customer. In order to implement a desired change in the Nav Model for the customer, I had to write 3 very small backing beans. They compiled fine, the taskflow let me add them as managed beans. It even new about these backing beans, presumably because I compiled them. I made changes to the .jsff file to use them and that worked fine. However the metadata.mar created when I deploy the application does not have these new classes, so they will not get put into the WC_Spaces server when I use WLST to import the metadata. Can anybody tell me how to get new backing beans into WebCenter Spaces?
    I cant be the only one who has had to do this.
    Thanks.

    I don't know if you can import as part of the metadata import but an alternative will be to create a shared library out of your java classes and referencing the shared lib in spaces.

  • Opening new browser window from backing bean

    Is it possible to open new window from backing bean?
    Regards, Simy

    quite sure its not possibleIt is possible !! But a fifferent way of doint it!
    I assume this is what you want ! on click of a button you want to go to the backing bean and come back with the new page on a new window !!
    Do the following! On click of a button, call a javascript method which does the following
    window.open('/jsf/somepage.jsf',.....)In the constructor of the backing bean, do the backend processing and set the fields of teh backing bean. And when the page gets rendered its as good as what you want...

  • Backing bean usage question

    Hi guys,
    I'm quite new to JSF, and I was wondering wether this is the correct way to use a backing bean.
    I got a page, with two inputText boxes, 'name' and 'age'. When I submit that page, some simple validation is invoked and the page will call the submit() function in the backing bean.
    In the submit function, I want to get the values that are stored in the request scope, and that is where I'm not sure what to do...
    Should I just call 'this.getName()' and 'this.getAge()' ? It feels not right to me for some reason; I'm used to messing around in the request maps for those values and I was wondering if I should use the facesContext instead ? Either way seems to work, but I just want to use JSF the way it was ment to be used :-)
    Thanks lots!

    Hi, thanks for your reply
    So basically you mean that I have a regular bean (the VO) which I instantiate in the managed bean, after I press the submit button ?
    E.g.
    Submit() -> get values from facesContext -> create VO with those values ?
    Just asking because right now I have the properties that I want to have inside my managed bean. You suggest I should separate these properties in their own bean ?
    Thanks :-)
    Message was edited by:
    Ophyr

  • JSF Page -- Backing Bean -- Non-JSF Page ...

    Hi
    I have a JSF page where the user enters data and submits by clicking on the Submit button. My backing bean then takes the data and processes it. After successful processing, I want to direct the user to a non-JSF page.
    What is the best way of achieving this?
    Thanks

    I am doing the following to get the desired effect now:
    FacesContext ctx = FacesContext.getCurrentInstance();
    ExternalContext ectx = ctx.getExternalContext();
    HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
    String nextUrl = "....";
    response.sendRedirect(nextUrl);
    Is there a better way?

  • To get value of a ADFdropdown in backing bean without submit button

    hi all,
    It maybe a very easy thing to do ,but please could you help me with this as I am new to ADF?I have a dropdown whose value i need in my backing bean without the use of a submit button..
    please do help me out!!!!

    Hi Frank ,
    Thank You for replying...
    But even after autosubmit=true, it didnt work..
    i shall post the code below,could u please throw more light on it?
    <af:selectOneChoice value="#{bindings.fetchbusinessservicesVO1Pagename.inputValue}"
    label="#{bindings.fetchbusinessservicesVO1Pagename.label}"
    binding="#{GiveAccess.selectOneChoice1}"
    id="selectOneChoice1" >
    <f:selectItems value="#{bindings.fetchbusinessservicesVO1Pagename.items}"
    binding="#{GiveAccess.selectItems1}"
    id="selectItems1"/>
    </af:selectOneChoice>
    <af:commandButton text="commandButton 1"
    binding="#{GiveAccess.commandButton1}"
    id="commandButton1"
    action="#{GiveAccess.getItemsList}"/>
    When i use Command button it works fine..but i want the same functionality without the command button.(GiveAccess is the backing bean where i want the value from dropdown)

  • How to add a backing bean for an existing jsp

    Hi You Experts,
    I am fixing an application built by someone else. In the application, some jsps do not have the associated backing beans. Now I want to add a backing bean to go with a particular jsp so that I can write codes there. How can I do this, please?
    Thanks in advance,
    ZD

    Hi Shay (and Others),
    As such a newbie, I cannot seem to find the "little arrow" or "binding property" you mentioned. I am using jdev 10.3.3.0. After I click on a component (an af:inputText), all I see is an "Edit Binding" link at the bottom of the Property Inspector. That link actually takes me to the binding of the component and attribute in the ViewObject.
    Also, when I followed your second suggestion (Design menu -> page properties->auto bind), I got a new backing file, but it's empty. i.e., it did not capture any existing components on the jsp.
    Please help me more. Thank you very much.
    ZD

  • Open URL in a new browser from a JSF backing bean

    I want to use commandButton action in jsf to launch a new browser instead of using commandLink.
    How do you launch url in a new browser window by firing up a method in backing bean?
    So far I am able to launch a URL within the same browser window. Here is my code:
    In jsp file:
    <h:commandButton rendered="#{openDataList.valueModifiable}" value="link" action="#{openDataList.link}" />
    In backing bean:
    public void link()
         try{
         FacesContext faces = FacesContext.getCurrentInstance();
         faces.responseComplete();
         ExternalContext context = faces.getExternalContext();
         context.redirect("http://www....");      }
         catch(java.io.IOException e)
    ...

    with a commandButton i dont belive you can
    well there are ways you can use javascript window.open
    or you can use a commanLink ans set the target
    but from my understanding there is no way to open a new browser from the backing beans ( this is because this is a client function and your backing beans are on the sever )

  • JSF Backing Bean State Being Lost Prior to Submit

    ISSUE
    I have an attribute in a backing bean for a drop-down list in a JSF that loses its state before I submit the page, which causes data updates to the backing bean dependent upon its state to be ignored.
    CONTEXT
    The JSF in question has a selectOneMenu drop-down list that determines whether or not several inputText fields will be rendered. The selectOneMenu is bound to an enum in the backing bean, and there are conditional accessors allowing the JSF to determine which inputTexts should be included in the current view. The three valid values of the drop-down are "ALL", "RANGE" and "SINGLE". The page is request scoped, a requirement of this project.
    Here is the JSF tag for the selectOneMenu drop-down list:
    <h:selectOneMenu disabled="#{not backingBean.newEntry}"
        id="tCriteria"
        value="#{backingBean.tCriteria}"
        onchange="submit()">
        <f:selectItems value="#{backingBean.possibleTCriteria}" />
    </h:selectOneMenu>And here are the RANGE selection-specific inputText controls:
    <h:inputText disabled="#{not backingBean.newEntry}"
        rendered="#{backingBean.tRange}"
        id="startTIndex"
        value="#{backingBean.tIndex}" />
    <h:inputText disabled="#{not backingBean.newEntry}"
        rendered="#{backingBean.tRange}"
        id="endTIndex"
        value="#{backingBean.endTIndex}" />Here is how I initialize the backing bean for the drop-down list attribute:
    * The current "t" criteria.
    private TCriteria tCriteria = TCriteria.ALL;And there are basic accessor/mutator methods for it. All of this works pretty well, with one problem. If I select "RANGE" in the drop-down, the appropriate inputText fields appear in the view. When I submit the page with values in the inputText fields, the value of the drop-down in the backing bean has been reset to its default initial value ("ALL") without having been updated through its mutator. Thus, when values in the backing bean are updated from the JSF, the conditional inputText fields are ignored, as they appear to have been deemed irrelevant during the update phase by the invalid state of the backing bean for the drop-down.
    To test my theory, I changed the default value of the backing bean attribute for the drop-down to be "RANGE", and made it final. The page behaves perfectly in updating the backing bean with the values entered for the conditionally-displayed inputText controls. This tells me that the invalid state of the backing bean drop-down list attribute must be the problem. Furthermore, I have tried using "disabled=", "readonly=" and "rendered=" on the conditional inputText fields, and none of that seems to make a difference. I also tried using a ValueChangeHandler, but that didn't do anything about it.
    Note - the backing bean does realize that the correct state for the drop-down should be "RANGE", but only AFTER the backing bean has received its updated values from the page controls.
    Has anyone seen anything like this? I haven't read anything in previous posts about an issue like this, but it has to be something someone has seen before. Maybe related to using the enum type? Thanks.

    Hi,
    did your web.xml file had any parameter regarding explicitly indicating the way to save state?
    I mean something like
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
      </context-param>One last question: did you stay with request scope beans or session ones?
    Greetings.
    MogaRick

  • What is the best way to submit an ADF Faces form from a backing bean?

    I would like to submit a JSF form at the end of a backing bean method (actually a ReturnEvent), and wonder if someone could supply an example of the "best practices" approach.
    Thanks!!
    Jeffrey

    Thanks for the reply Frank!
    Actually, what I want would be the equivalent of a resetActionListener.
    After performing "bindings.getOperationBinding("DeleteTrip").execute()" I would like the page to redraw itself with empty controls.
    I have included a resetActionListener in my commandLink, but the page is not redrawn after the operation.
    If I hit the reload button on my browser (after the operation has completed), I get the desired behavior.
    I've just added this comment to someone else's question you replied to on the following thread:
    Re: How to programatically resetAction after rollback?
    Thanks again!!
    Jeffrey

  • HT201289 Aperture keeps 3.6 on Yosemite keeps going "non responsive" while trying to create a new vault or back up to an existing vault. Any help would be great.

    Aperture keeps 3.6 on Yosemite keeps going "non responsive" while trying to create a new vault or back up to an existing vault.
    Any help would be great.

    Where is your vault stored? Is it on a drive with the correct formatting - MacOS Extended (Journaled)?

  • Add new row to a table bound to ArrayList in backing bean

    Hi,
    I have a Arralist<CustomObject> in the backing bean.
    I want to create a table with Add/Delete new row buttons which will add/delete objects from the ArrayList.
    I am using Jdev 11g and I am not using ADF BC.
    Please give me some heads up or links.
    Thanks

    Then that's your problem, change the class to something like:
    public class TableHandlerConsumer
        private static final String LIST_PAGE_FLOW_ATTR = "consumers:" + TableHandlerConsumer.class.getName();
        public TableHandlerConsumer()
            Collection data = new ArrayList<Consumer>();
            buildModel(data);
            tableModel = new SortableModel(data);
            Map<String, Object> pageFlowScope = RequestContext.getCurrentInstance().getPageFlowScope();
            pageFlowScope.put(LIST_PAGE_FLOW_ATTR, tableModel);
        private void buildModel(Collection data)
            baris.add(new Consumer("", "", "", "", ""));
            baris.add(new Consumer("", "", "", "", ""));
            baris.add(new Consumer("", "", "", "", ""));
        public void addRow()
            Consumer consumer = new Consumer();
            ((Collection)tableModel.getWrappedData()).add(Consumer);
        public SortableModel getTableModel()
            Map<String, Object> pageFlowScope = RequestContext.getCurrentInstance().getPageFlowScope();
            return (SortableModel)pageFlowScope.get(LIST_PAGE_FLOW_ATTR);
    }Note that if you're using 10g then change Requestcontext to AdfFacesContext and getPageFlowScope to getProcessScope
    Regards,
    ~ Simon

  • How open new browser in JSF after executing backing bean method

    hi All,
    Can you please tell me how to open a new browser after executing action method in bean.
    I have writen one java script function, i am passing the string url which i got from the backing bean action method.
    First of all i want to execute action method then only javascript function.
    waiting for your quick reply.
    thanks & regards
    bhushanam.

    hi,
    That command link in data table. The requirement is like this:
    I have datatable, the columns are
    1) <h:selectBooleanCheckbox ....
    2) <h:commandLink ....
    requirement 1:
    if user select the boolean check box and click the command link
    then I want to execute the backing bean action method , it returns string url and show in new browser window( popup window with toolbar ).
    requirement 2:
    if user not select the boolean check box and click the command link then I want to excute the backing bean action method, it returns string url and show in the same browser ( through navigation rule we can show that page.)
    Please look the below command link code.......
    <h:commandLink id="belegnr" onmousedown="return showPopupWindowForInvoiceForGraphicImage( '#{row.importKz}', '#{row.blnChecked}', '#{InvoiceMecBoxBean.printInvoiceFilePath}');" styleClass="input" style="color:blue" value="#{row.belegnr}" action="#{InvoiceMecBoxBean.editLinkAction}"/>
    Can u please give me the idea istead of command link can we use outputlink to fullfil the requirement?. Or any suggestion please......
    Here in my case commandlink value is differenet and after action the return value is different to show in new window. that is problem here.
    thanks & regards
    bhushanam.

  • Shift focus to new tab opened in backing bean

    Hi,
    I have a tree whose nodes are displayed as command links. On click of these links I have corresponding method action in my backing bean that generates the URL which is opened as a new tab on the browser. Below is what my method looks like in the backing bean.
    FacesContext ctx = FacesContext.getCurrentInstance();
    ExtendedRenderKitService erks =
    Service.getService(ctx.getRenderKit(), ExtendedRenderKitService.class);
    String url = "window.open('http://www.google.com', '_blank')";
    erks.addScript(FacesContext.getCurrentInstance(), url);
    We are using IE7 and the problem is that the browser opens a new tab but doesn't shift the focus to the new tab. I added a simple af:goLink on my page with the targetFrame as"_blank" and it works fine. But its the script that I'm calling from my backing bean doesn't behave in the same way. We cannot ask the users to change their browser settings.
    Jdev 11.1.1.5.0.
    Thanks

    Thanks Frank,
    Since I'm generating this URL from the backing bean I did change the script in my backing bean to
    ExtendedRenderKitService erks = Service.getService(ctx.getRenderKit(), ExtendedRenderKitService.class);
    erks.addScript(FacesContext.getCurrentInstance(), "window.open('http://www.google.com', '_blank').focus();");
    But that also didn't move the focus to the new tab. When I embed the same string in the javascript on the page(jspx) it works fine.

Maybe you are looking for