Hi,

"user id" is the username. I want to set user id into session attribute.
After I call WebSession.bind(), now the problem is solved.
But why MyauthenticatedWebSession is temporary in default? (no session id)



Pedro Santos-6 wrote:
> 
> Please, what is "user id" that you refers?
> 
> On Wed, Sep 9, 2009 at 5:31 AM, Anders <[email protected]> wrote:
> 
>> Hi,
>>
>> I can get the user id attribute from my authenticatedWebSession in a
>> role-needed page.
>> But I can't get user id when I go to no-role-needed page.
>> Do I need to override newSession() method in WebApplication?
>> Please help me~
>>
>> Belows are my classes:
>>
>> public class HelloWorldApplication extends AuthenticatedWebApplication
>> {
>>  @Override
>>  protected Class<? extends AuthenticatedWebSession> getWebSessionClass()
>>  {
>>    return MyAuthenticatedWebSession.class;
>>  }
>>
>>  @Override
>>  protected Class<? extends WebPage> getSignInPageClass()
>>  {
>>    return MySignInPage.class;
>>  }
>> }
>>
>> public class MyAuthenticatedWebSession extends AuthenticatedWebSession
>> {
>>  public MyAuthenticatedWebSession(Request request)
>>  {
>>    super(request);
>>  }
>>
>>  @Override
>>  public boolean authenticate(String username, String password)
>>  {
>>    //do some authentication process
>>    setAttribute("userId", username);
>>    return true;
>>  }
>>
>>  @Override
>>  public Roles getRoles()
>>  {
>>    if(isSignedIn())
>>    {
>>      Roles roles = getUserRoles();
>>      if(roles == null)
>>      {
>>        roles = new Roles();
>>        roles.add("ROLE_USER");
>>      }
>>      return roles;
>>    }
>>    return null;
>>  }
>>
>>  public static MyAuthenticatedWebSession get()
>>  {
>>    return (MyAuthenticatedWebSession) Session.get();
>>  }
>>
>>  public String getUserId()
>>  {
>>    return (String) getAttribute("userId");
>>  }
>>
>>  public Roles getUserRoles()
>>  {
>>    return (Roles) getAttribute("roles");
>>  }
>> }
>>
>> --
>> ------------------
>> ~Mia は 最高!~
>> ------------------
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Can%27t-get-attribute-from-AuthenticatedWebSession-for-no-role--needed--page.-tp25360742p25364126.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to