wood burning stoves 2.0*
The moose likes JSF and the fly likes How to assign a value to a request scoped managed bean property? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to assign a value to a request scoped managed bean property?" Watch "How to assign a value to a request scoped managed bean property?" New topic
Author

How to assign a value to a request scoped managed bean property?

Amy N. Snow
Greenhorn

Joined: Apr 09, 2008
Posts: 20
I have a action method called submit. That method is inside a managed bean with session scope. At the end of the submit() method I want to invalidate the session but I would like to keep a number to display after the session is invalidated. How can I store that number in a request scoped managed bean?

This is the request managed bean:

<managed-bean>
<managed-bean-name>confirmationMsg</managed-bean-name>
<managed-bean-class>beans.Messages</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>message</property-name>
<property-class>java.lang.String</property-class>
<value>#{form.number}</value>
</managed-property>
</managed-bean>

I've tried setting the value to the property number of the form bean but the value is blank after I invalidate the session.


Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

After you invalidate the session, EVERYTHING below application scope should be wiped out.

However, request-scope objects have an even shorter lifespan. They get reconstructed for each HTTP request. Hence the name "request" scope.


Customer surveys are for companies who didn't pay proper attention to begin with.
Amy N. Snow
Greenhorn

Joined: Apr 09, 2008
Posts: 20
Tim Holloway wrote:After you invalidate the session, EVERYTHING below application scope should be wiped out.

However, request-scope objects have an even shorter lifespan. They get reconstructed for each HTTP request. Hence the name "request" scope.


Everything below the session, not the application scope. I know the request scope beans are alive through the request that's why I need one after I invalidate the session, but I do not know how to store information into the request managed bean from the backing bean method. I've seen the setValue method from the ValueBind but I understand that is deprecated in JSF 1.2 and I wanted to know the best approach.
 
Don't get me started about those stupid light bulbs.
 
subject: How to assign a value to a request scoped managed bean property?
 
Similar Threads
Correct way to assign a value to a managed bean from a class?
JSF and REST urls
Obtaining an instance of a Managed Bean declared with Application Level Scope
Similar logic:notPresent in JSF
JSF backingbean value is null always.