Link to home
Start Free TrialLog in
Avatar of nohacks
nohacksFlag for United States of America

asked on

How do I reset a session bean to default values ?? jsf bean

How do I reset a session bean to default values ??  jsf bean

I know I can use this to remove it from session...

FacesContext
      .getCurrentInstance().getApplication()
      .createValueBinding( "#{SearchTestFormBean}")
      .setValue(FacesContext.getCurrentInstance(), null );


I would like to reset it to the original values of the session bean.


thanks

Phil
 
Avatar of mohammedf
mohammedf
Flag of Palestine, State of image

use the following:
getSessionBean1().setAttributeName(null);

Open in new window

Avatar of nohacks

ASKER

Thanks for the quick response...

can you explain more??

      <managed-bean>
            <managed-bean-name>SearchTestFormBean</managed-bean-name>
            <managed-bean-class>com.test.java.SearchTestFormBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
      
This is my bean

Now how do I use that???

I would like this in my jsp header include file. This way when
the user enters the search screen it does not have previous selections.


Thanks again

Phil
what is the problem with this code?

FacesContext
      .getCurrentInstance().getApplication()
      .createValueBinding( "#{SearchTestFormBean}")
      .setValue(FacesContext.getCurrentInstance(), null );

Open in new window

Avatar of nohacks

ASKER

FacesContext
      .getCurrentInstance().getApplication()
      .createValueBinding( "#{SearchTestFormBean}")
      .setValue(FacesContext.getCurrentInstance(), null );

This code takes the SearchTestFormBean out of the session. When I walk thru it with the debugger the bean is null.

I want to reload the SearchTestFormBean to the original default values. This way none of the previous search items are set in the session.

Phil

 
try this:
getSessionBean1.setSearchTestFormBean(null);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of nohacks
nohacks
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial