You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Geoff Longman <gl...@intelligentworks.com> on 2003/08/25 19:36:52 UTC

User's locale suggestion

Throwing this out there as I am building tap apps while using the new
Spindle (and tweaking it at the same time) so my plate is full right now...

Our App has localized labels that are coming out of resource bundles that
are not under Tapestry's control so getString() is not help. We are able to
get things we need by calling:

ModelStrings.getString(key, locale)

So we need the current user's locale.

I'm currently calling cycle.getEngine().getLocale all over the place.

I have made a base class for components to simplify this (I also have a page
class that is pretty much the same).

public class LocaleAwareComponent extends BaseComponent implements
PageRenderListener
{
    private Locale fUserLocale;

    /**
    * Pull the users' Locale from the engine before a render.
    */
    public void pageBeginRender(PageEvent event)
   {
        fUserLocale = event.getRequestCycle().getEngine().getLocale();
    }
    protected Locale getUserLocale()
    {
        return fUserLocale;
    }
}

Would be neat if pages and components could implement an interface, say
IUserLocaleAware then bytecode magic occurs and something like the above is
automagic. I guess this could be built into AbstractComponent and but not
every component or page would need this feature.

Thoughts?

Geoff

Geoffrey Longman
Intelligent Works Inc.


Re: User's locale suggestion

Posted by Geoff Longman <gl...@intelligentworks.com>.
nevermind.


----- Original Message ----- 
From: "Howard M. Lewis Ship" <hl...@comcast.net>
To: "'Tapestry development'" <ta...@jakarta.apache.org>
Sent: Monday, August 25, 2003 3:50 PM
Subject: RE: User's locale suggestion


> How about getPage().getLocale()?  Pages know the locale.
> 
> --
> Howard M. Lewis Ship
> Creator, Tapestry: Java Web Components
> http://jakarta.apache.org/tapestry
> http://jakarta.apache.org/commons/sandbox/hivemind/
> http://javatapestry.blogspot.com
> 
> > -----Original Message-----
> > From: Geoff Longman [mailto:glongman@intelligentworks.com] 
> > Sent: Monday, August 25, 2003 1:37 PM
> > To: tapestry-dev@jakarta.apache.org
> > Subject: User's locale suggestion
> > 
> > 
> > Throwing this out there as I am building tap apps while using 
> > the new Spindle (and tweaking it at the same time) so my 
> > plate is full right now...
> > 
> > Our App has localized labels that are coming out of resource 
> > bundles that are not under Tapestry's control so getString() 
> > is not help. We are able to get things we need by calling:
> > 
> > ModelStrings.getString(key, locale)
> > 
> > So we need the current user's locale.
> > 
> > I'm currently calling cycle.getEngine().getLocale all over the place.
> > 
> > I have made a base class for components to simplify this (I 
> > also have a page class that is pretty much the same).
> > 
> > public class LocaleAwareComponent extends BaseComponent 
> > implements PageRenderListener {
> >     private Locale fUserLocale;
> > 
> >     /**
> >     * Pull the users' Locale from the engine before a render.
> >     */
> >     public void pageBeginRender(PageEvent event)
> >    {
> >         fUserLocale = event.getRequestCycle().getEngine().getLocale();
> >     }
> >     protected Locale getUserLocale()
> >     {
> >         return fUserLocale;
> >     }
> > }
> > 
> > Would be neat if pages and components could implement an 
> > interface, say IUserLocaleAware then bytecode magic occurs 
> > and something like the above is automagic. I guess this could 
> > be built into AbstractComponent and but not every component 
> > or page would need this feature.
> > 
> > Thoughts?
> > 
> > Geoff
> > 
> > Geoffrey Longman
> > Intelligent Works Inc.
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
> 


RE: User's locale suggestion

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
How about getPage().getLocale()?  Pages know the locale.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Geoff Longman [mailto:glongman@intelligentworks.com] 
> Sent: Monday, August 25, 2003 1:37 PM
> To: tapestry-dev@jakarta.apache.org
> Subject: User's locale suggestion
> 
> 
> Throwing this out there as I am building tap apps while using 
> the new Spindle (and tweaking it at the same time) so my 
> plate is full right now...
> 
> Our App has localized labels that are coming out of resource 
> bundles that are not under Tapestry's control so getString() 
> is not help. We are able to get things we need by calling:
> 
> ModelStrings.getString(key, locale)
> 
> So we need the current user's locale.
> 
> I'm currently calling cycle.getEngine().getLocale all over the place.
> 
> I have made a base class for components to simplify this (I 
> also have a page class that is pretty much the same).
> 
> public class LocaleAwareComponent extends BaseComponent 
> implements PageRenderListener {
>     private Locale fUserLocale;
> 
>     /**
>     * Pull the users' Locale from the engine before a render.
>     */
>     public void pageBeginRender(PageEvent event)
>    {
>         fUserLocale = event.getRequestCycle().getEngine().getLocale();
>     }
>     protected Locale getUserLocale()
>     {
>         return fUserLocale;
>     }
> }
> 
> Would be neat if pages and components could implement an 
> interface, say IUserLocaleAware then bytecode magic occurs 
> and something like the above is automagic. I guess this could 
> be built into AbstractComponent and but not every component 
> or page would need this feature.
> 
> Thoughts?
> 
> Geoff
> 
> Geoffrey Longman
> Intelligent Works Inc.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>