You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hernán <he...@gmail.com> on 2012/01/13 16:06:06 UTC

Struts 2 Internationalization Tiles 2

Hi there, I'm applying internationalization to a WebApp, and so far so
good, almost everything is working as expected. When the user accesses the
site, depending on its browser configuration he sees the web site in his or
her preferred language, if he or she decides to change the language, I
change the locale programmatically and it works as it should... The problem
is that I use Tiles2 and when changing the Locale programmatically, the
WebApp is not using the Tiles's definitions as it should... It keeps using
the definitions that are in the preferred language of the browser
configuration.
The question is then: how do I change Tiles locale programmatically as I
did in Struts2 with request_locale? Any ideas? Thank you.

-- 
Hernán

Re: JSP help

Posted by Jeffrey Black <je...@gmail.com>.
Eric -- Give the following link a look.

http://blogs.oracle.com/Didier/entry/jstl_10_in_jsp_20_pages

Best,

jb

On Fri, Jan 13, 2012 at 1:10 PM, Eric Reed <ER...@mail.nysed.gov> wrote:

> 1000 + jsps... all coded like <%=srtcld%>, and I can't use find replace
> because java calls in the JSP's start and end with <%java crap%>
>
> Very professional stuff I get to deal with.
>
> I think I'm just going to write a small program to update them all unless
> someone has a good solution.
>
>
> >>> Gabriel Belingueres <be...@gmail.com> 1/13/2012 2:07 PM >>>
> Isn't the variable defined in page scope?
> A single ${srtcld} EL expression should suffice.
>
> Gabriel
>
> 2012/1/13 Eric Reed <ER...@mail.nysed.gov>:
> > Everyone,
> >
> > I know this has nothing to do with Struts but maybe someone one this
> mailing list has encountered this problem before.
> >
> > We have a massive project that I am upgrading from 10g to 11G. Going
> from OAS to weblogic. This project was developed in '04 using '99 - 2001
> technologies (Struts 1.1, jstl 1.0... etc) over 35 developers were on the
> project for 4 years... I'm the only one left.
> >
> > I have successfully updated our 1000+ ejb's and session beans but the
> JSP's are killing me.
> >
> > I am not a front-end developer, and for most cases we do this for var's
> on a jsp page:
> >
> > <bean:define id="srtcId" name="roles" property="srtcId" />
> >
> > .. later in the jsp srtcId is referenced like : value="<%=srtcId%>"
> >
> > JDeveloper 11g hates this and will not compile any of the JSP's. I tried
> several different approaches to try and get these to compile without
>  success so any help would be great.
> >
> > Also the post parameter being returned to the action class is just a
> string of what is in the value field.
> >
> > Thank you in advance.
> > Eric
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: JSP help

Posted by Eric Reed <ER...@MAIL.NYSED.GOV>.
1000 + jsps... all coded like <%=srtcld%>, and I can't use find replace because java calls in the JSP's start and end with <%java crap%>

Very professional stuff I get to deal with.

I think I'm just going to write a small program to update them all unless someone has a good solution.


>>> Gabriel Belingueres <be...@gmail.com> 1/13/2012 2:07 PM >>>
Isn't the variable defined in page scope?
A single ${srtcld} EL expression should suffice.

Gabriel

2012/1/13 Eric Reed <ER...@mail.nysed.gov>:
> Everyone,
>
> I know this has nothing to do with Struts but maybe someone one this mailing list has encountered this problem before.
>
> We have a massive project that I am upgrading from 10g to 11G. Going from OAS to weblogic. This project was developed in '04 using '99 - 2001 technologies (Struts 1.1, jstl 1.0... etc) over 35 developers were on the project for 4 years... I'm the only one left.
>
> I have successfully updated our 1000+ ejb's and session beans but the JSP's are killing me.
>
> I am not a front-end developer, and for most cases we do this for var's on a jsp page:
>
> <bean:define id="srtcId" name="roles" property="srtcId" />
>
> .. later in the jsp srtcId is referenced like : value="<%=srtcId%>"
>
> JDeveloper 11g hates this and will not compile any of the JSP's. I tried several different approaches to try and get these to compile without  success so any help would be great.
>
> Also the post parameter being returned to the action class is just a string of what is in the value field.
>
> Thank you in advance.
> Eric
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org 
> For additional commands, e-mail: user-help@struts.apache.org 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org 
For additional commands, e-mail: user-help@struts.apache.org 




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: JSP help

Posted by Gabriel Belingueres <be...@gmail.com>.
Isn't the variable defined in page scope?
A single ${srtcld} EL expression should suffice.

Gabriel

2012/1/13 Eric Reed <ER...@mail.nysed.gov>:
> Everyone,
>
> I know this has nothing to do with Struts but maybe someone one this mailing list has encountered this problem before.
>
> We have a massive project that I am upgrading from 10g to 11G. Going from OAS to weblogic. This project was developed in '04 using '99 - 2001 technologies (Struts 1.1, jstl 1.0... etc) over 35 developers were on the project for 4 years... I'm the only one left.
>
> I have successfully updated our 1000+ ejb's and session beans but the JSP's are killing me.
>
> I am not a front-end developer, and for most cases we do this for var's on a jsp page:
>
> <bean:define id="srtcId" name="roles" property="srtcId" />
>
> .. later in the jsp srtcId is referenced like : value="<%=srtcId%>"
>
> JDeveloper 11g hates this and will not compile any of the JSP's. I tried several different approaches to try and get these to compile without  success so any help would be great.
>
> Also the post parameter being returned to the action class is just a string of what is in the value field.
>
> Thank you in advance.
> Eric
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


JSP help

Posted by Eric Reed <ER...@MAIL.NYSED.GOV>.
Everyone,

I know this has nothing to do with Struts but maybe someone one this mailing list has encountered this problem before.

We have a massive project that I am upgrading from 10g to 11G. Going from OAS to weblogic. This project was developed in '04 using '99 - 2001 technologies (Struts 1.1, jstl 1.0... etc) over 35 developers were on the project for 4 years... I'm the only one left.

I have successfully updated our 1000+ ejb's and session beans but the JSP's are killing me. 

I am not a front-end developer, and for most cases we do this for var's on a jsp page:

<bean:define id="srtcId" name="roles" property="srtcId" />

.. later in the jsp srtcId is referenced like : value="<%=srtcId%>"

JDeveloper 11g hates this and will not compile any of the JSP's. I tried several different approaches to try and get these to compile without  success so any help would be great.

Also the post parameter being returned to the action class is just a string of what is in the value field.

Thank you in advance.
Eric



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 Internationalization Tiles 2

Posted by Hernán <he...@gmail.com>.
Thank you very much, It's very interesting, though I needed something like
this to get the current language anyway:

jQuery:

            $.getJSON("/i18nUtil/GetLanguageJSONAction",
                function(language) {
                    locale = language;
                }
            );

Java class:

public class GetLanguageJSONAction extends ActionSupport implements
SessionAware {
    private String language;
    private Map<String, Object> session;

    public String execute() {

        Object requestLocale = getSession().get("request_locale");

        language = requestLocale != null &&
!requestLocale.toString().equalsIgnoreCase("") ? requestLocale.toString() :
getLocale().getLanguage();

        return Constants.SUCCESS;
    }

    @JSON(serialize=true, name="locale")
    public String getLanguage() {
        return language;
    }

    public void setLocale(String locale) {
        this.language = locale;
    }

    public Map<String, Object> getSession() {
        return session;
    }

    @Override
    public void setSession(Map<String, Object> session) {
        this.session = session;
    }

}



On Fri, Jan 13, 2012 at 4:41 PM, Jeffrey Black <je...@gmail.com>wrote:

> Have you given this plugin a whirl?
>
> http://code.google.com/p/jquery-i18n-properties/
>
>
> On Fri, Jan 13, 2012 at 1:28 PM, Hernán <he...@gmail.com> wrote:
>
> > Thank you it worked!
> >
> >    public String execute() {
> >        String requestLocale = getRequestLocale();
> >        Map<String, Object> session = getSession();
> >        session.put("request_locale", requestLocale);
> >        //I added the following line of code to ChangeLocaleAction:
> >        session.put(DefaultLocaleResolver.LOCALE_KEY, new
> > Locale(requestLocale));
> >        //and Tiles started working.
> >        String previousAction = session.get("previousAction").toString();
> >        String previousNamespace =
> > session.get("previousNamespace").toString();
> >        setRedirectToAction(previousAction);
> >        setRedirectToNamespace(previousNamespace);
> >
> >        return Constants.SUCCESS;
> >    }
> >
> > Now do you know how to get request_locale in javascript... I have some
> > jquery plugins that need a locale var to apply internationalization..
> Thank
> > you...
> >
> > On Fri, Jan 13, 2012 at 2:14 PM, Jeffrey Black <jeffblack360@gmail.com
> > >wrote:
> >
> > > Just for kicks try setting the following in your Session map:
> > >
> > > *public static final String LOCALE_KEY = "org.apache.tiles.LOCALE";*
> > >
> > > [1]
> > >
> > >
> >
> http://tiles.apache.org/framework/tiles-core/xref/org/apache/tiles/locale/impl/DefaultLocaleResolver.html
> > >
> > > On Fri, Jan 13, 2012 at 11:01 AM, Hernán <he...@gmail.com> wrote:
> > > >
> > > > Yes I've done that, I have tiles.xml for english, tiles_es.xml for
> > > spanish
> > > > and tiles_pt-xml for portuguese... The thing is that it works with
> the
> > > > browser settings, when somebody changes the locale by a link of the
> web
> > > > app, it works for struts2 but not tiles2 definition titles, I'm about
> > to
> > > > try with DefaultLocale. Do you know how can I get request_locale
> > > parameter
> > > > at client level? to use with javascript and jquery?
> > > >
> > > > On Fri, Jan 13, 2012 at 1:54 PM, Jeffrey Black <
> jeffblack360@gmail.com
> > > >wrote:
> > > >
> > > > > I seem to recall needing a different tiles definition for each
> locale
> > > you
> > > > > wish to support?  Does that ring a bell to anyone?
> > > > >
> > > > > I will double-check some documentation when I get a chance.
> > > > >
> > > > > jb
> > > > >
> > > > > On Fri, Jan 13, 2012 at 9:06 AM, Hernán <he...@gmail.com> wrote:
> > > > >
> > > > > > Hi there, I'm applying internationalization to a WebApp, and so
> far
> > > so
> > > > > > good, almost everything is working as expected. When the user
> > > accesses
> > > > > the
> > > > > > site, depending on its browser configuration he sees the web site
> > in
> > > his
> > > > > or
> > > > > > her preferred language, if he or she decides to change the
> > language,
> > > I
> > > > > > change the locale programmatically and it works as it should...
> The
> > > > > problem
> > > > > > is that I use Tiles2 and when changing the Locale
> programmatically,
> > > the
> > > > > > WebApp is not using the Tiles's definitions as it should... It
> > keeps
> > > > > using
> > > > > > the definitions that are in the preferred language of the browser
> > > > > > configuration.
> > > > > > The question is then: how do I change Tiles locale
> programmatically
> > > as I
> > > > > > did in Struts2 with request_locale? Any ideas? Thank you.
> > > > > >
> > > > > > --
> > > > > > Hernán
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Hernán
> > >
> >
> >
> >
> > --
> > Hernán
> >
>



-- 
Hernán

Re: Struts 2 Internationalization Tiles 2

Posted by Jeffrey Black <je...@gmail.com>.
Have you given this plugin a whirl?

http://code.google.com/p/jquery-i18n-properties/


On Fri, Jan 13, 2012 at 1:28 PM, Hernán <he...@gmail.com> wrote:

> Thank you it worked!
>
>    public String execute() {
>        String requestLocale = getRequestLocale();
>        Map<String, Object> session = getSession();
>        session.put("request_locale", requestLocale);
>        //I added the following line of code to ChangeLocaleAction:
>        session.put(DefaultLocaleResolver.LOCALE_KEY, new
> Locale(requestLocale));
>        //and Tiles started working.
>        String previousAction = session.get("previousAction").toString();
>        String previousNamespace =
> session.get("previousNamespace").toString();
>        setRedirectToAction(previousAction);
>        setRedirectToNamespace(previousNamespace);
>
>        return Constants.SUCCESS;
>    }
>
> Now do you know how to get request_locale in javascript... I have some
> jquery plugins that need a locale var to apply internationalization.. Thank
> you...
>
> On Fri, Jan 13, 2012 at 2:14 PM, Jeffrey Black <jeffblack360@gmail.com
> >wrote:
>
> > Just for kicks try setting the following in your Session map:
> >
> > *public static final String LOCALE_KEY = "org.apache.tiles.LOCALE";*
> >
> > [1]
> >
> >
> http://tiles.apache.org/framework/tiles-core/xref/org/apache/tiles/locale/impl/DefaultLocaleResolver.html
> >
> > On Fri, Jan 13, 2012 at 11:01 AM, Hernán <he...@gmail.com> wrote:
> > >
> > > Yes I've done that, I have tiles.xml for english, tiles_es.xml for
> > spanish
> > > and tiles_pt-xml for portuguese... The thing is that it works with the
> > > browser settings, when somebody changes the locale by a link of the web
> > > app, it works for struts2 but not tiles2 definition titles, I'm about
> to
> > > try with DefaultLocale. Do you know how can I get request_locale
> > parameter
> > > at client level? to use with javascript and jquery?
> > >
> > > On Fri, Jan 13, 2012 at 1:54 PM, Jeffrey Black <jeffblack360@gmail.com
> > >wrote:
> > >
> > > > I seem to recall needing a different tiles definition for each locale
> > you
> > > > wish to support?  Does that ring a bell to anyone?
> > > >
> > > > I will double-check some documentation when I get a chance.
> > > >
> > > > jb
> > > >
> > > > On Fri, Jan 13, 2012 at 9:06 AM, Hernán <he...@gmail.com> wrote:
> > > >
> > > > > Hi there, I'm applying internationalization to a WebApp, and so far
> > so
> > > > > good, almost everything is working as expected. When the user
> > accesses
> > > > the
> > > > > site, depending on its browser configuration he sees the web site
> in
> > his
> > > > or
> > > > > her preferred language, if he or she decides to change the
> language,
> > I
> > > > > change the locale programmatically and it works as it should... The
> > > > problem
> > > > > is that I use Tiles2 and when changing the Locale programmatically,
> > the
> > > > > WebApp is not using the Tiles's definitions as it should... It
> keeps
> > > > using
> > > > > the definitions that are in the preferred language of the browser
> > > > > configuration.
> > > > > The question is then: how do I change Tiles locale programmatically
> > as I
> > > > > did in Struts2 with request_locale? Any ideas? Thank you.
> > > > >
> > > > > --
> > > > > Hernán
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Hernán
> >
>
>
>
> --
> Hernán
>

Re: Struts 2 Internationalization Tiles 2

Posted by Hernán <he...@gmail.com>.
Thank you it worked!

    public String execute() {
        String requestLocale = getRequestLocale();
        Map<String, Object> session = getSession();
        session.put("request_locale", requestLocale);
        //I added the following line of code to ChangeLocaleAction:
        session.put(DefaultLocaleResolver.LOCALE_KEY, new
Locale(requestLocale));
        //and Tiles started working.
        String previousAction = session.get("previousAction").toString();
        String previousNamespace =
session.get("previousNamespace").toString();
        setRedirectToAction(previousAction);
        setRedirectToNamespace(previousNamespace);

        return Constants.SUCCESS;
    }

Now do you know how to get request_locale in javascript... I have some
jquery plugins that need a locale var to apply internationalization.. Thank
you...

On Fri, Jan 13, 2012 at 2:14 PM, Jeffrey Black <je...@gmail.com>wrote:

> Just for kicks try setting the following in your Session map:
>
> *public static final String LOCALE_KEY = "org.apache.tiles.LOCALE";*
>
> [1]
>
> http://tiles.apache.org/framework/tiles-core/xref/org/apache/tiles/locale/impl/DefaultLocaleResolver.html
>
> On Fri, Jan 13, 2012 at 11:01 AM, Hernán <he...@gmail.com> wrote:
> >
> > Yes I've done that, I have tiles.xml for english, tiles_es.xml for
> spanish
> > and tiles_pt-xml for portuguese... The thing is that it works with the
> > browser settings, when somebody changes the locale by a link of the web
> > app, it works for struts2 but not tiles2 definition titles, I'm about to
> > try with DefaultLocale. Do you know how can I get request_locale
> parameter
> > at client level? to use with javascript and jquery?
> >
> > On Fri, Jan 13, 2012 at 1:54 PM, Jeffrey Black <jeffblack360@gmail.com
> >wrote:
> >
> > > I seem to recall needing a different tiles definition for each locale
> you
> > > wish to support?  Does that ring a bell to anyone?
> > >
> > > I will double-check some documentation when I get a chance.
> > >
> > > jb
> > >
> > > On Fri, Jan 13, 2012 at 9:06 AM, Hernán <he...@gmail.com> wrote:
> > >
> > > > Hi there, I'm applying internationalization to a WebApp, and so far
> so
> > > > good, almost everything is working as expected. When the user
> accesses
> > > the
> > > > site, depending on its browser configuration he sees the web site in
> his
> > > or
> > > > her preferred language, if he or she decides to change the language,
> I
> > > > change the locale programmatically and it works as it should... The
> > > problem
> > > > is that I use Tiles2 and when changing the Locale programmatically,
> the
> > > > WebApp is not using the Tiles's definitions as it should... It keeps
> > > using
> > > > the definitions that are in the preferred language of the browser
> > > > configuration.
> > > > The question is then: how do I change Tiles locale programmatically
> as I
> > > > did in Struts2 with request_locale? Any ideas? Thank you.
> > > >
> > > > --
> > > > Hernán
> > > >
> > >
> >
> >
> >
> > --
> > Hernán
>



-- 
Hernán

Re: Struts 2 Internationalization Tiles 2

Posted by Jeffrey Black <je...@gmail.com>.
Just for kicks try setting the following in your Session map:

*public static final String LOCALE_KEY = "org.apache.tiles.LOCALE";*

[1]
http://tiles.apache.org/framework/tiles-core/xref/org/apache/tiles/locale/impl/DefaultLocaleResolver.html

On Fri, Jan 13, 2012 at 11:01 AM, Hernán <he...@gmail.com> wrote:
>
> Yes I've done that, I have tiles.xml for english, tiles_es.xml for spanish
> and tiles_pt-xml for portuguese... The thing is that it works with the
> browser settings, when somebody changes the locale by a link of the web
> app, it works for struts2 but not tiles2 definition titles, I'm about to
> try with DefaultLocale. Do you know how can I get request_locale parameter
> at client level? to use with javascript and jquery?
>
> On Fri, Jan 13, 2012 at 1:54 PM, Jeffrey Black <jeffblack360@gmail.com
>wrote:
>
> > I seem to recall needing a different tiles definition for each locale
you
> > wish to support?  Does that ring a bell to anyone?
> >
> > I will double-check some documentation when I get a chance.
> >
> > jb
> >
> > On Fri, Jan 13, 2012 at 9:06 AM, Hernán <he...@gmail.com> wrote:
> >
> > > Hi there, I'm applying internationalization to a WebApp, and so far so
> > > good, almost everything is working as expected. When the user accesses
> > the
> > > site, depending on its browser configuration he sees the web site in
his
> > or
> > > her preferred language, if he or she decides to change the language, I
> > > change the locale programmatically and it works as it should... The
> > problem
> > > is that I use Tiles2 and when changing the Locale programmatically,
the
> > > WebApp is not using the Tiles's definitions as it should... It keeps
> > using
> > > the definitions that are in the preferred language of the browser
> > > configuration.
> > > The question is then: how do I change Tiles locale programmatically
as I
> > > did in Struts2 with request_locale? Any ideas? Thank you.
> > >
> > > --
> > > Hernán
> > >
> >
>
>
>
> --
> Hernán

Re: Struts 2 Internationalization Tiles 2

Posted by Hernán <he...@gmail.com>.
Yes I've done that, I have tiles.xml for english, tiles_es.xml for spanish
and tiles_pt-xml for portuguese... The thing is that it works with the
browser settings, when somebody changes the locale by a link of the web
app, it works for struts2 but not tiles2 definition titles, I'm about to
try with DefaultLocale. Do you know how can I get request_locale parameter
at client level? to use with javascript and jquery?

On Fri, Jan 13, 2012 at 1:54 PM, Jeffrey Black <je...@gmail.com>wrote:

> I seem to recall needing a different tiles definition for each locale you
> wish to support?  Does that ring a bell to anyone?
>
> I will double-check some documentation when I get a chance.
>
> jb
>
> On Fri, Jan 13, 2012 at 9:06 AM, Hernán <he...@gmail.com> wrote:
>
> > Hi there, I'm applying internationalization to a WebApp, and so far so
> > good, almost everything is working as expected. When the user accesses
> the
> > site, depending on its browser configuration he sees the web site in his
> or
> > her preferred language, if he or she decides to change the language, I
> > change the locale programmatically and it works as it should... The
> problem
> > is that I use Tiles2 and when changing the Locale programmatically, the
> > WebApp is not using the Tiles's definitions as it should... It keeps
> using
> > the definitions that are in the preferred language of the browser
> > configuration.
> > The question is then: how do I change Tiles locale programmatically as I
> > did in Struts2 with request_locale? Any ideas? Thank you.
> >
> > --
> > Hernán
> >
>



-- 
Hernán

Re: Struts 2 Internationalization Tiles 2

Posted by Jeffrey Black <je...@gmail.com>.
I seem to recall needing a different tiles definition for each locale you
wish to support?  Does that ring a bell to anyone?

I will double-check some documentation when I get a chance.

jb

On Fri, Jan 13, 2012 at 9:06 AM, Hernán <he...@gmail.com> wrote:

> Hi there, I'm applying internationalization to a WebApp, and so far so
> good, almost everything is working as expected. When the user accesses the
> site, depending on its browser configuration he sees the web site in his or
> her preferred language, if he or she decides to change the language, I
> change the locale programmatically and it works as it should... The problem
> is that I use Tiles2 and when changing the Locale programmatically, the
> WebApp is not using the Tiles's definitions as it should... It keeps using
> the definitions that are in the preferred language of the browser
> configuration.
> The question is then: how do I change Tiles locale programmatically as I
> did in Struts2 with request_locale? Any ideas? Thank you.
>
> --
> Hernán
>