struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alireza Fattahi <afatt...@yahoo.com>
Subject Struts 2 Access messages with JSTL instead of s:text
Date Wed, 28 May 2014 04:34:29 GMT
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
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message