struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Jorge <rvjs...@gmail.com>
Subject Re: Passing parameters to <s:property>
Date Fri, 05 Mar 2010 10:16:57 GMT
Thank you both for your help. I got this working with your suggestions. :)

I made an experiment with various ways of working this out. Here are the
results. They may be helpful to others looking for the same answer.

1. Doesn't work
            name('Locale.US'): <s:property value="name('Locale.US')" />


2. Doesn't work
            name(Locale.US): <s:property value="name(Locale.US)" />


3. Doesn't work
            getName(Locale.US): <s:property value="getName(Locale.US)" />


4. Works. notice the ' in the parameter
            getName('Locale.US'): <s:property value="getName('Locale.US')"
/>

5. Works. i tried something similar before but I was just using 'name'
instead of 'getName'
            getName(@java.util.Locale@US): <s:property
value="getName(@java.util.Locale@US)" />


6. Doesn't wok. I tried this previously. See nº5
            name(@java.util.Locale@US): <s:property
value="name(@java.util.Locale@US)" />


7. Works but probably only because there is also a getName(String s) where s
is the locale as a string
            name('en_US'): <s:property value="getName('en_US')" />


8. Works but probably only because there is also a getName(String s) where s
is the locale as a string
            name('US'): <s:property value="getName('US')" />



Also, I did not need to use struts.ognl.allowStaticMethodAccess

-------------

>
> i still think you should be looking at this differently and using the i18n
interceptor and resource bundles to handle different
> languages.

@adam: I'm using Liferay and this is a class provided by the Portal to get
the names of the pages in localized format. The getName method (without
parameters) returns XML content with the various languages so I need to get
the right locale using the provided getName(Locale locale).

Perhaps I could create an additional class where I would store the
information I need in an already localized format and handle this in the
Action.

Best Regards,
Ricardo





2010/3/4 adam pinder <apinder@hotmail.co.uk>

>
>
>
> just pass an alias to the locale in the parameter
>
>
>
> <s:property value="getName('US')"/>
>
>
>
> and let the getName class handle the actual locale.
>
>
>
> adam
>
> > Date: Thu, 4 Mar 2010 18:20:19 +0100
> > Subject: Re: Passing parameters to <s:property>
> > From: lukasz.lenart@googlemail.com
> > To: user@struts.apache.org
> >
> > 2010/3/4 Ricardo Jorge <rvjsapi@gmail.com>:
> > > PS: I've just tried the following but it did not work
> > > <s:property value="name(@java.util.Locale@US)" />
> >
> > Take a look on some examples here [1] and try
> > <s:property value="getName(@java.util.Locale@US)" />
> >
> > [1] http://struts.apache.org/2.x/docs/ognl-basics.html
> >
> >
> > Regards
> > --
> > Łukasz
> > http://www.lenart.org.pl/
> > Kapituła Javarsovia 2010
> > http://javarsovia.pl
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
> _________________________________________________________________
> Tell us your greatest, weirdest and funniest Hotmail stories
> http://clk.atdmt.com/UKM/go/195013117/direct/01/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message