Setting fooId to null DOES remove the object from session, but
judging from the sources of ApplicationStateManagerImpl (its
_stateObjects never removes items),
the stateFlag will continue to return true...

This happens 'cause the map that holdes the ASOs still has the
"foo" key (that now points to null)

So, the workaround seems to be to add
boolean isFooReallySelected() {
return isFooSelected() && getFooId()!=null; }

You could add an issue about this at
https://issues.apache.org/jira/browse/TAPESTRY,
https://issues.apache.org/jira/browse/TAPESTRY-912 looks related

On Fri, Jun 19, 2009 at 5:09 PM, <espera...@cumego.com> wrote:
> Hi!
> I'm using Tapestry 4.1.
> How to remove previously created ASO from session, so that @InjectStateFlag
> could return false again?
>
> Sample code (assume that ASO "foo" is already set, so the flag returns
> TRUE):
>
> @InjectState("foo")
> public abstract Long getFooId();
> public abstract void setFooId(Long id);
>
> @InjectStateFlag("foo")
> public abstract boolean isFooSelected();
>
> // used in form by property selection model with an empty option
> public abstract Long getSelectedFooId();
> public abstract void setSelectedFooId(Long id);
>
> // called on submit
> public void changeFoo() {
> //HERE: how to remove ASO when getSelectedFoo() is null?
> setFooId(getSelectedFooId()); // setFooId(null) doesn't change flag
> }
>
> Is there a way to do this? Or maybe there is another approach to manage
> state across pages?
> Of course, i don't want to invalidate session. :-)
>
> Best regards,
> Przemysław Wojnowski
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



-- 
Andreas Andreou - andy...@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to