Ok, hold on, a couple of comments further down.

On 5/12/06, Bruno Borges <[EMAIL PROTECTED]> wrote:
Eelco, the problem I listed in my previous email was that it is kind of
impossible to create a Session object passing some User info to
ISessionFactory.

Let's say we have something like this:

class CustomForm ... {

    void onSubmit() {
        User u = (User) getModelObject();
        SomeServiceFromIoC service = ...
        service.authenticate(u);
        ... // ok, user is authenticated and now can have access. lets set
his session to his Locale
        Locale l = u.getUserLocale();
        getSession().setFixedLocale(l);
        getSession().setAttribute("loggedUser", u);
    }


The first remark is that it's not the recommended way to use
setAttribtue directly. In fact that's why we made that method final
protected, so the above code can't work. The recommended way is to
have a session object like

public class MySession extends WebSession {

  private User user;
}

etc. The nice thing about that is that you have strong typed sessions.
One of the things we're proud to have with Wicket! :)

So, say you want to vary the locale to be either some default, or
based on the logged in user... you would get something like:

public class MySession extends WebSession {

  private User user;

 public Locale getLocale() {
   if (user == null)  {
     return myDefaultLocale;
  } else {
     return user.getLocale();
 }
 }
}

You login form just has to set the current user in the session, and
you're done. And instead of the myDefaultLocale above, you can
implement anything you want, including checking out the request
headers, cookies, etc (remember you can get the current request cycle
during a request anywhere by calling RequestCycle.get()).

Hope that clears it up a bit,

Eelco


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to