You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alireza Fattahi <af...@yahoo.com.INVALID> on 2014/06/02 12:29:47 UTC

Re: Struts 2 Access messages with JSTL instead of s:text

As mentioned the ${action.getText('sample')} will work, but this is JSTL method invocation and you need JSTL 2.2 (ex: tomcat 7)
 
~Regards,
~~Alireza Fattahi 


On Friday, 30 May 2014, 16:20, Yaragalla Muralidhar <ya...@gmail.com> wrote:
 


you have to use fmt tags in jstl. Using jstl is a good idea.

*Thanks and Regards,*
Muralidhar Yaragalla.

*http://yaragalla.blogspot.in/ <http://yaragalla.blogspot.in/>*



On Wed, May 28, 2014 at 10:04 AM, Alireza Fattahi <af...@yahoo.com>
wrote:

> In struts 2 the
>
>     <s:property value="#pageTitle" />
>
> (is equivalent to...)
>
>     JSTL: ${pageTitle}
>
> I use JSTL version which is more compact.
>
> Can we do the same thing with application messages?! To get text from
> message resources we do as below:
>
>     <s:text name="label.sample" />
>
> Now, is there any JSTL version insteadof `<s:text/>` ?
>
>
> ----------
>
>
> Meanwhile, I tried to find a way to pass textprovider to jsp. But I could
> not find a way
>
>      public class BaseActionSupport extends ActionSupport{
>
>       //Same as ActionSupport
>       private TextProvider Provider; //with setter and getter
>
>       public TextProvider getSampleTextProvider() {
>
>                 TextProviderFactory tpf = new TextProviderFactory();
>                 if (container != null) {
>                     container.inject(tpf);
>                 }
>                 return  tpf.createInstance(getClass(), this);
>     }
>
> }
> In jsp:
>
>     ${provider.text("label.password")} //Error The function text must be
> used with a prefix when a default namespace is not specified
>
> Is it a correct approach?!
>
> PS: In the
> http://notsoyellowstickies.blogspot.com/2011/05/making-struts-2-and-jstl-share-message.html
> mentioned that I can somehow share struts 2 and jstl messages, but I should
> still use `<fmt:message key="sample.label"/>`
>
>
> ~Regards,
> ~~Alireza Fattahi