Hi Christian,

thank you for the quick response and very good explanation.

Poitras Christian wrote:
> 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.

Okey, this seems to be the only good approach for my problem I think, 
because everything stays the way it was before. Even the objects are the 
same (Reference).

> 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.

This works for the most cases, but not for mine. Because I have to save 
a more complex object and references within this object have to keep 
alive too. So I think the way of buffering these object into hidden 
fields is not a good idea in this special case.

> 3) Use @Session on the complex fields. See 
> http://www.stripesframework.org/display/stripes/Save+ActionBean+fields+in+session

This is also possible for me, thanks for it.

> 4) Save complex fields in session manually: 
> getContext().getSession().setAttribute().

Okey, this is the exact same way I'm doing it now. But not as nice as 
the annotaion things.

> 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

Thanks for this explanation. I read this paragraph many times, but could 
not really understand it. Especially this sentence confused me:

"This list is stored in flash scope so that the messages are available 
to the current request (should the ActionBean forward to a page) and in 
the next request (should the ActionBean redirect to a page)."

and I thought this value will be available in the next request too, but 
thanks for the explanation anyway.

Regards,
Christoph

> -----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


------------------------------------------------------------------------------
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