I run the code and request.getAttribute(USER) returns null in dispatch()
function. So I output the Request to see what happens; then notice that they
(Request in Login.java Page and AccessController.java) are two difference
objects.
Now it looks like I can obtain the User data by marking the User object as
SessionState in Login.java Page.
public class Login{
...
@SessionState
private User user;
...
Object onSubmitFromLogin(){
user = new User(...);
}
}
Then retrieve User object from dispatch() in AccessController.java
public boolean dispatch(Request request, Response response) throws
IOException{
...
if(asm.exists(User.class)){
User u = asm.get(User.class);
...
}
}
However, this rise another question for me - is this a recommended way to
obtain a temporary User object (because User object in Login Page is only
constructed temporarily and passed to the backend side for verification)?
>From my viewpoint, it seems to me that if I have similar situation, then I
>will put too many temporary objects into Session. Also, how if I have other
>User object which holds different information (e.g. User object obtained from
>database), but needs to exist at the same time as that temporarily constructed
>User object? Will the later override the one that is constructed temporarily
>(I read Tapestry website saying if I have the same type marked with
>SessionState annotation, they will use the same reference regardless of their
>variable name)?
Thanks for advice,
I really appreciate it.
--- On Mon, 8/6/09, Thiago H. de Paula Figueiredo <[email protected]> wrote:
> From: Thiago H. de Paula Figueiredo <[email protected]>
> Subject: Re: Obtain the data inside RequestGlobals question
> To: "Tapestry users" <[email protected]>
> Date: Monday, 8 June, 2009, 9:49 PM
> Em Mon, 08 Jun 2009 18:40:42 -0300,
> Neo Anderson <[email protected]>
> escreveu:
>
> > What way is the correct method to set data in the
> Request object in Page and retrieve it back from dispatch
> function?
>
> Have you really tested the result of that code instead of
> just comparing the two Request instances?
>
> By the way, unless your Tapestry code is inside an
> application that uses another framework (thus you need to
> read or write info in the session so the other framework car
> access it), use the ApplicationStateManager service
> instead.
>
> --Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]