Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Amy N. Snow
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18226
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Amy N. Snow
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic