On 9/27/05, Kent Tong <[EMAIL PROTECTED]> wrote:
> Ryan <crumley <at> gmail.com> writes:
> > In tapestry 4 I have the nice option of injecting the user data ASO
> > into my page and calling getUserData() to retrieve it. The problem is
> > that as soon as I call getUserData() it will cause my application to
> > go stateful. The only method I have seen to avoid this is to use the
> > StateObjectPersistenceManager to determine if that ASO exists. The
> > problem with this approach is that I cant inject the ASO into my page
> > so I am forced to retrieve it myself then cast it to the correct type
> > and continue my logic:
>
> You can still inject the ASO. As long as you don't call the getter,
> the ASO won't be created.
True, what would be nice though if there were some way of telling the
getter not to create the ASO if it doesn't exist. That way a client
does not have to use the StateObjectPersistenceManager to determine if
the ASO exists (similar to how tapestry3 getVisit() from a page or
component did not create the visit if it didnt exist, it returned
null).
Current tapestry 4:
@InjectState("userData")
public UserData getUserData();
@InjectObject(...)
public StateObjectPersistenceManager getPersistenceManager();
...
if(getPersistenceManager().exists("userData") &&
getUserData().isAuthenticated() ) {
...
}
Simplified suggestion?:
@InjectState("userData" forceCreate=false)
public UserData getUserData();
...
if(getUserData() != null && getUserData().isAuthenticated() ) {
...
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]