The locale is FIXED in the session when it is set.
It is only initialized when the session is created.
so session.setLocale(userLocale) works fine.
And i would make my own Session so that you don't have to do setAttribute() but just call: setUser(user)
johan
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);
}
If the API is going to not provide a public way to override current Session's locale, this kind of code will never be possible. And somewhere in the RequestCycle, this Locale setting must be checked before load any ResourceBundle.
On 5/12/06, Eelco Hillenius < [EMAIL PROTECTED]> wrote:So yeah, that's exactly my point. We should not have had that setting
in the first place. The fact that you can override getLocale in a
custom session object gives means you can employ any scheme you want,
including returning a default one (request headers, cookies) while a
user is not logged on, and when the user is logged on, return that
one.
AND as I stated, it is just wrong to have that setting as we can't
guarantee it. If you set it in your application but override getLocale
in your session, the whole setting is meaningless.
So: I propose to get rid of the setting and put up a FAQ entry in the
WIKI or something.
Eelco
On 5/12/06, Bruno Borges < [EMAIL PROTECTED]> wrote:
> Just one question:
>
> How to authenticate an user and right after that create a session with a
> Locale coming from the... database, for example? Remembering that the
> ISessionFactory is called from the (Custom)WebApplication that has no
> knowledge about any request, login form... anything.
>
> I think that, the way to set up a default Locale only in the time the
> Session object is created, it's not good, because sometimes the Session must
> already exist while the User hasn't authenticated yet. If you guys think in
> code this feature like the way it's been proposed, there will be no way to
> inform the ISessionFactory about some things like User info at logon time.
>
> Am I wrong?
>
>
> On 5/11/06, Eelco Hillenius < [EMAIL PROTECTED] > wrote:
> >
> I don't know. That seems to be the original idea of the default
> locale, though it never worked. Personally, I don't think such an
> option is that great. I would prefer letting you override the session
> object - you probably will do that anyway when you have to deal with
> things like users etc, and override the getLocale method. That's way
> more flexible too, as in that method you can check out the clients
> preferred locales, look up database settings and anything else you
> might want to do.
>
> Having just one way of doing things attracts more to me, and the
> convenience win is minimal for the corner case of fixing a locale for
> an application.
>
> Eelco
>
>
> On 5/11/06, Bruno Borges < [EMAIL PROTECTED] > wrote:
> > Wouldn't be useful to have a method that sets a Locale to be used, and if
> > this options is setted, Wicket should ignore user's locale?
> >
> >
> > On 5/11/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
> > >
> > > no, the default locale is used when we cannot figure out what the user's
> > local is afaik. since the browser is sending a locale that will be used.
> > >
> > >
> > > -Igor
> > >
> > >
> > >
> > >
> > > On 5/11/06, Bruno Borges < [EMAIL PROTECTED]> wrote:
> > > >
> > > > Shouldn't these calls override any locale the user is sending at the
> > request (from the browser)?
> > > >
> > > > getApplicationSettings().setDefaultLocale(new
> > Locale("pt", "BR"));
> > > > getResourceSettings().setDefaultLocale(new
> > Locale("pt", "BR"));
> > > >
> > > > I still get english messages, that comes from Application.properties.
> My
> > tought was that, overriding the default locale, I would get portuguese
> > messages.
> > > >
> > > > Regards
> > > >
> > > >
> > > > --
> > > > Bruno Borges
> > > > [EMAIL PROTECTED]
> > > > Sun Certified Java Programmer for 1.4
> > > > Sun Certified Web Component Developer for 1.4
> > >
> > >
> >
> >
> >
> >
> > --
> > Bruno Borges
> > [EMAIL PROTECTED]
> > Sun Certified Java Programmer for 1.4
> > Sun Certified Web Component Developer for 1.4
>
>
> -------------------------------------------------------
> 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?cmdlnk&kid0709&bid&3057&dat1642
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>
> --
>
> Bruno Borges
> [EMAIL PROTECTED]
> Sun Certified Java Programmer for 1.4
> Sun Certified Web Component Developer for 1.4
-------------------------------------------------------
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?cmdlnk&kid0709&bid&3057&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user--
Bruno Borges
[EMAIL PROTECTED]
Sun Certified Java Programmer for 1.4
Sun Certified Web Component Developer for 1.4
