How-to remove a jsf backing bean from session?

How can I find the reference to a backing bean (with session scope) and then remove the bean?
I may have painted myself into a corner. When most of my pages are navigated to, they get key info from session and then initially populate the page fields. I populate the fields in the constructor with values from the database based on the keys found in session. So the second time a particular page is called the values may be stale or completely unrelated to the page navigated from because the bean already exists and, naturally, the constructor is never called.
I'm thinking if I could remove the backing bean, jsf wouldn't find it so it would be recreated on subsequent navigations. Since the constructor would be called with every navigation to the page, the values would not be stale or unrelated.
Any help would be greatly appreciated.
TIA,
Al Malin

//To reset session bean
FacesContext
     .getCurrentInstance()
     .getApplication()
     .createValueBinding( "#{yourBeanName}").setValue(FacesContext.getCurrentInstance(), null );
//To get session bean reference
Object obj = FacesContext
          .getCurrentInstance()
          .getApplication()
          .createValueBinding("#{yourBeanName}")
          .getValue(FacesContext.getCurrentInstance());
YourSessionBean bean = (YourSessionBean)obj;

Similar Messages

  • How to get value in backing bean from application module

    Hi all.. I'm new in jdeveloper and adf..
    I need to use value from backing bean and use that value in application module.
    But I don't know how to get it.
    Do you a have any solution?

    suppose you have myMethod(String argumentName1,String argumentName2) in your Application Module
    then to access a method binding from a managed bean, use the following code,
      BindingContext bctx = BindingContext.getCurrent();
      BindingContainer bindings = bctx.getCurrentBindingsEntry();
      OperationBinding operationBinding =
           bindings.getOperationBinding("name_of_method_binding");
      //Here you can pass the parameters value to the AM method
      operationBinding.getParamsMap().put("argumentName1",value1);
      operationBinding.getParamsMap().put("argumentName2",value2);
      //invoke method
      operationBinding.execute();
      if (!operationBinding.getErrors().isEmpty()) {
         //check errors
         List errors = operationBinding.getErrors();
      //optional
      Object methodReturnValue = operationBinding.getResult();

  • How to remove Bean from session upon leaving the web page?

    Hi...
    I got the following problem
    I promote a user with a Datatable filled with data, each time the user enters the webpage with the table I go the DB and retrieve all relevant data again (so each time the user gets an OnLine representation of the DB)
    to archive that I defined the bean that pulls data from DB in Request scope. and it worked well... but now i added an option to export the table into Pdf made by a servlet.... now to be able to get the bean from the servlet i had to change the scope of the Bean to Session Scope... and all works fine.. BUT... now the page not showing OnLine representation of the DB.. cause its only created once , cause its inside Session Scope...
    My question is how can I remove the Bean from Session scope upon the user leaving the page (I don't want to remove the bean from session scope on the next called bean of the other page) i want to remove the Bean upon leaving the current web page... Or maybe force the constructor to be executed each time the Page is loaded (as if it was a Request scope bean)....
    Any ideas?
    Thanks ahead!
    Daniel.

    Hi,
    When you are moving to another page, you are performing an action right ?
    (i mean the request moving to Server side), if you do so, then clear the bean object values list.
    for example :
        private List<Integer> intList = new ArrayList<Integer>();
      public void clear()
       intList.clear();
    or
    store a new object in session, when ever u moved to the second page, so that the old object will be no longer
    in use, so it will be garbage collected.Regards,
    Sathya.

  • WebSphere Custering and JSF Backing Beans

    Hello All,
    Can anyone enlighten me on exactly how backing bean state is maintained by JSF?
    In what scope does JSF store the backing beans? (session perhaps)
    Does it make sense to use JSF without stateful backing beans?
    What would happen if a client post did not find its corresponding backing bean on the application server calling it?
    Background:
    In a clustered WebSphere Server environment, a client post may be directed to any one of the machines in the cluster. If the client post gets directed to a machine other then the machine that originally sent the client a response, the page will not find the corresponding page beans.
    It is possible to serialize session beans in WebSphere and have each machine share its memory with all the boxes in the cluster. However, this practice is not permitted in some environments.
    Any thoughts? Thanks in advance.

    I am probably not an expert on the subject. But here are some thoughts:
    1. A backing bean can have (application, session, request or None) as a scope.
    Less app or session scope beans the better (from server perspective). But
    There are practical reasons why you would want to use them in many cases.
    2. JSF supports Client State Saving mode. But keep in mind the overhead
    Involved (serialization, de-serialization, bandwidth,...).
    3. You probably need to read about WebSphere load balancing capability. From
    what I know it is somehow sophisticated. People typically use session affinity
    to force requests initiated by same session to be served by the same app
    server (enforced by network, hardware/software tools available to do so,...). Of
    course with failover mechanism to ensure high availability.
    Hope that helps!

  • JSF Backing bean / JSP interaction questions

    A few questions about JSF beans and JSP page interactions. Bear in mind that I'm new to both JSP and JSF, so a solution that might be obvious to the rest of the world may be new to me.
    1. Can I pass a parameter to the backing bean method from an "action" attribute:
    <h:commandLink action="#{TableData.SortRec}">
    <h:outputText value="#{msgs.selectedHeader}"/>
    </h:commandLink>
    I'd like to call the same method from several controls, but pass it a parameter to determine which field to sort on.
    2) Is there a way for a backing bean method to determine which control invoked it?
    3) Is there a way to access JSF backing bean methods from JSP tags. I'd like to do some conditional page assembly based on a JSF bean property... JSF doesn't appear to have a conditional like JSP's <c:if>, but I could use JSP's if it could access the JSF bean.

    Could you pl tell me how to pass parameter thru CommandButton
    I have the following situation
    1) greetingList.faces which list the Ids & greeting Text
    Id Text
    1 Hello World
    2 Hello World
    2) Pl note Ids are h:commandLink. A click on the Id will render greetingForm.faces with data pertaining to that Id and with Update h:CommandButton
    3) When i click Update button it results in the following error
    javax.faces.FacesException: Error calling action method of component with id greetingForm:_id4
    Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{greetingForm.update}
    Caused by: java.lang.NullPointerException
    So i verified with h:message that Id is passed as Null when click on Update button. I also checked greetingForm.faces has a not null value by printing <h:outputText value="#{greetingForm.message.id}"/>
    So i guess the Id value is overwriteen with null. Also i have defined Id as property in managed bean
    <managed-bean-name>greetingForm</managed-bean-name>
    <managed-bean-class>com.mycompany.GreetingForm</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>id</property-name>
    <value>#{param.id}</value>
    </managed-property>
    Any pointers/suggestions at the earliest on how to pass the value of Id on a click of update button from greetingForm.faces to greetingForm.java will be highly appreciated
    I am willing to upload my war file
    Regards
    Bansi

  • How can you erase old back up from my external drive which i placed in the trash?

    I removed some old back up from time machine which are on my external drive and it now in the trash. But the old back up is not erasing from my trash can. How can you removed this from the trash without reformatting the external drive.

    You really should not remove any Time Machine backups using that or any other method.
    Go to > Time Machine - Frequently Asked Questions 12 and scroll down to the section in gray at the bottom of the article.
    For more great Time Machine info, see > Apple  OSX  and  Time  Machine  Tips

  • How to remove "Other..." from my sign-in screen?

    How to remove "Other..." from my sign-in screen?
    I was trying to change an Administrator Account by starting from my Leopard Install DVD and from the Utilities menu choosing Reset Password, etc. A longish story involving my inability to shut-down the computer while others are signed in but not actually using the computer. In Tiger I was able, since moving to Leopard I need to go into each of their accounts and manually log each of them out. A headache.
    For right right now I need to get rid of the Other... account name, etc from my sign-in screen. How do I do this in plain English please? I find all this Admin jargon does my head in.
    Cheers, SZ

    V.K. wrote:
    You need to disable the root user. From what I understand you enabled it from the install DVD's password reset.
    Use [these instructions|http://docs.info.apple.com/article.html?artnum=106290] to disable it.
    Those instructions led me down this path, I have not the head to deal with them again today. My eyes glaze-over listening to myself read them aloud. SZ
    Message was edited by: ShakuZen

  • How to remove my credit card information from my icloud account?

    how to remove my credit card information from my icloud account?

    iTunes Store: Changing Account Information
    http://support.apple.com/kb/HT1918
     Cheers, Tom

  • TS3274 How to remove an old iCloud account from my IPad.  The account (email) was on my dad's name and he resently change it and now i can't  reset or delete his iCloud account without his password.  Please advise on the procedure.  Thanks.

    How to remove an old iCloud account from my IPad.  The account (email) was on my dad's name and he resently change it and now i can't  reset or delete his iCloud account without his password.  Please advise on the procedure.  Thanks.

    If you are trying to activate an iPad or iPhone and it is asking for a previous owners Apple ID and password, you have encountered the Activation Lock. This is a security feature that prevents thieves from setting up and using a stolen or lost iPad or iPhone. You have no alternative. You must use the previous owner's password to get permission to use the device. If you cannot get the password your father put on the iPad you will never be able to activate the device and no one can help you do it.

  • How to remove plug in ._v1_.swf from safari

    How to remove plug in ._v1_.swf from safari. Can't do it the usual ways.

    Please post the crash report.

  • HT4847 How can I move a back up from an old iPhone out of iCloud but not delete it?

    How can I move a back up from an old iPhone out of icloud and onto my own storage device? I don't want to delete it, I just don't want to keep it in iCloud

    Unfortunately you do not have direct access to iOS backs in iCloud.
    I am not sure what you mean by:
    It's locked with an enterprise (third party code)
    Do you mean it is a corporate device and managed by Mobile Device Management software?
    If so the IT department can reset the passcode.
    Other than that, there is no third party iOS app that can lock the device at that level unless it is jailbroken and then no one here can help you.

  • HT201269 how can i restore a back-up from an older phone?

    how can i restore a back-up from an older phone?
    I did a back up from my iPhone 4 on iTunes but I don't seem to be able to restore on my new 5c

    Restoring from an older iOS to a newer iOS version is fine.  It's going the other way that would be a problem.
    You do need a late version of iTunes on your computer to be able to work with the new iPhone.  The current iTunes version is 11.1.3.  If your iTunes is old, download the latest from
    http://www.apple.com/itunes/download

  • The songs I've added to my itunes library from cd's are no longer showing up in my itunes list. how do I put them back on from my ipod?

    the songs I've added to my itunes library are no longer showing on my itunes account. how do I load them back on from my ipod

    What do you mean by " on my itunes account"
    and "in my itunes list"?

  • How do I restore the back up from my old iPhone 5 which is IOS 8.1.3 to my new iPhone 6 which is IOS 8? It's not coming up as an available back up restore option?

    How do I restore the back up from my old iPhone 5 which is IOS 8.1.3 to my new iPhone 6 which is IOS 8? It's not coming up as an available back up restore option? Am I able to set up as a new iPhone and then update the new phone to IOS 8.1.3 and then restore from my old iPhone 5 back up at that stage?

    Setup your new phone, then update to iOS 8.1.3. Once done: Settings>General>Reset>Erase All Content & Settings". At the setup screen you'll now be able to select your old phone's backup.

  • HT204053 How do I restore a back up from two weeks ago from my icloud to my iphone

    How do I restore a back up from two weeks ago from my icloud to my iphone

    If you apps are still in iTunes, you should be able to sync them back to your computer.  Otherwise, if you have iOS 5 (5.01) on your phone you could redownload them by launching Apps, press the Purchased button at the bottom, press Purchased at the top, then Not On This Phone.  This will list your apps and allow you to redownload them.  If you've purchased apps using multiple Apple IDs, you will have to sign in to each of these IDs to be able to download all your apps (by going to Settings>Store>tap on the Apple ID, sign out, sign back in using another ID).

Maybe you are looking for