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> on 2014/05/25 07:00:50 UTC

Access messages with JSTL instead of s:text

In struts 2 the 
<s:propertyvalue="#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:textname="label.sample"/>
Now, is there any JSTL version instead of <s:text/> ? 
________________________________

Meanwhile, I tried to find a way to pass textprovider to jsp. But I could not find a way
publicclassBaseActionSupportextendsActionSupport{//Same as ActionSupportprivateTextProviderProvider;//with setter and getterpublicTextProvidergetSampleTextProvider(){TextProviderFactorytpf =newTextProviderFactory();if(container !=null){container.inject(tpf);}returntpf.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
 
~Regards,
~~Alireza Fattahi