Hi,

You have a many possibilities. But unless you put the ActionBean in session 
(@SessionScope), a new instance will be created for each request.
1) Use @SessionScope. See 
http://www.stripesframework.org/display/stripes/annotation+reference#annotationreferen...@sessionscope
Only one instance of this ActionBean will exists for each session.
2) Use @Wizard. See 
http://www.stripesframework.org/display/stripes/annotation+reference#annotationreferen...@wizard
Request parameters that are not hidden in page will be automatically added at 
the end of the form in hidden fields. This is the closest solution to what you 
want.
3) Use @Session on the complex fields. See 
http://www.stripesframework.org/display/stripes/Save+ActionBean+fields+in+session
4) Save complex fields in session manually: 
getContext().getSession().setAttribute().

The reason FlashScope does not work is that it exists only to execute 
redirect-after-post.
It is well documented here: 
http://www.stripesframework.org/display/stripes/State+Management#StateManagement-RedirectafterPost

Christian

-----Original Message-----
From: Christoph Oberhofer [mailto:zitronenmeli...@gmx.at]
Sent: Monday, April 20, 2009 4:36 PM
To: stripes-users@lists.sourceforge.net
Subject: [Stripes-users] Problems with FlashScope - Lifetime of Object

Hi there,

What I want to achieve:
I want to make a wizard which goes from one step to another and saves a complex 
object between all these requests. I thought about FlashScope but it does not 
work the way I want.

I have troubles when using the FlashScope - approach to store Objects between 
two requests. The problem is, that the ActionBean which I flash is not 
populated in the next request. Which means, regarding to the example at the 
end, when the method "step2" is called, the Set is null.
But why?

Anyone an idea how to store and repopulate ActionBeans for using ONE and the 
SAME instance for the whole wizard?

Thanks in advance,
Regards,
Christoph

WizardTestActionBean.java
/*---------------------------------------------------------*/
public class WizardTestActionBean extends BasicActionBean {

   private Set<String> setToLife = null;

   @HandlesEvent("step1")
   public Resolution performStep1(){
     setToLive = new HashSet<String>();
     setToLive.add("Hello");
     setToLive.add("There");

     return new RedirectResolution("/wizard/step2.jsp").flash(this);
   }

   @HandlesEvent("step2")
   public Resolution performStep2(){
     if(setToLive == null || setToLive.size() != 2){
       System.err.println("setToLive not populated");
       return getContext().getSourcePageResolution();
     }
     return new RedirectResolution("/wizard/step3.jsp").flash(this);
   }
}
/*---------------------------------------------------------*/

wizard/step1.jsp

/*---------------------------------------------------------*/
<body>
   <stripes:form beanclass="itndb.stripes.WizardTestActionBean">
     <stripes:submit name="step1" value="next"></stripes:submit>
   </stripes:form>
</body>
/*---------------------------------------------------------*/

wizard/step2.jsp

/*---------------------------------------------------------*/
<body>
   <stripes:form beanclass="itndb.stripes.WizardTestActionBean">
     <stripes:submit name="step2" value="next"></stripes:submit>
   </stripes:form>
</body>


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and around Java (TM) 
technology - register by April 22, and save $200 on the JavaOne (SM) 
conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p 
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to