You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mraible <ma...@raibledesigns.com> on 2008/04/10 02:46:59 UTC

i18n Tags in FreeMarker Decorator for SiteMesh

I'm using 2.1.1-SNAPSHOT of the sitemesh and rest plugins.
FreeMarker/SiteMesh is working fine. However, I'm unable to use i18n tags in
my decorator. In src/main/resources/com/company/app/package.properties, I
have:

webapp.name=Foo
webapp.tagline=Bar

In my decorators/default.ftl, I have:

[@s.text name="webapp.name"/]

And it renders:

webapp.name

Any idea why my Struts FreeMarker tag isn't being processed? I have the
following in my web.xml:

    <filter-mapping>
        <filter-name>struts-cleanup</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

Thanks,

Matt
-- 
View this message in context: http://www.nabble.com/i18n-Tags-in-FreeMarker-Decorator-for-SiteMesh-tp16599500p16599500.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: i18n Tags in FreeMarker Decorator for SiteMesh

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
mraible wrote:
> I tried [@s.property value="text('key')"/] and that doesn't seem to work
> either. I don't have a struts.xml or struts.properties in my project. I
> tried putting the i18n bundle in all packages using it at the Action level
> (ActionName.properties), but that didn't work either. Creating a
> src/main/resources/struts.properties with the following in it is the only
> thing that seems to work.
>
> struts.custom.i18n.resources=messages
>
> And then putting my keys in src/main/resources/messages.properties.
>
> AFAICT, i18n bundles at the action/package level seems to be completely
> broken in 2.1.1.
>
> Matt
>
>   

Sorry Matt, I can't replicate this issue.

I created a freemarker decorator that uses @s.text and it was able to find:
 - resources in the global resource bundle (specified via 
struts.custom.i18n.resources)
 - resources in the named resource bundle when contained within an 
@s.i18n tag
 - resources in the actionName.properties resource bundle
 - resources in the package.properties resource bundle

I used each technique one at at a time, inside and outside a decorator 
and in both FTL and JSP. My test action extended ActionSupport for the 
TextProvider. 

However, I'm am still convinced there's a problem. A possible scenario:
  - getText matches the first TextProvider found in the value stack.  
Not the first TextProvider providing the requested key.
  - some operations can push another TextProvider onto the stack (in 
front of the action).  The i18n tag does this.
  - there are cases where the alternate TextProvider is not popped off 
the stack (see https://issues.apache.org/struts/browse/WW-2539)

I've started cleaning up the implementation to isolate it.  See my post 
in struts-dev.

regards,
 Jeromy Evans

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


Re: i18n Tags in FreeMarker Decorator for SiteMesh

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
mraible wrote:
> I tried [@s.property value="text('key')"/] 
I've already found that in 2.0.x this OGNL expression executed 
getText(String) but in 2.1.x it only matches the method "text(String)".
I'm not sure when that changed in the OGNL implementation, but the new 
form seems correct as it's method call not a property. 
I've already replaced one occurrence of "text('key')" with 
"getText('key')" in the code but there's probably others. That's one of 
the consequences of allowing loosely typed expressions to creep into code.

I'll definitely look further into this today as its been affecting me 
for a while too.


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


Re: i18n Tags in FreeMarker Decorator for SiteMesh

Posted by mraible <ma...@raibledesigns.com>.
I tried [@s.property value="text('key')"/] and that doesn't seem to work
either. I don't have a struts.xml or struts.properties in my project. I
tried putting the i18n bundle in all packages using it at the Action level
(ActionName.properties), but that didn't work either. Creating a
src/main/resources/struts.properties with the following in it is the only
thing that seems to work.

struts.custom.i18n.resources=messages

And then putting my keys in src/main/resources/messages.properties.

AFAICT, i18n bundles at the action/package level seems to be completely
broken in 2.1.1.

Matt


Jeromy Evans - Blue Sky Minds wrote:
> 
> Hi Matt,
> 
> is it only the @s.text tag that isn't working?  eg. is @s.property
> working?
> 
> I've suspected there's a problem with the text tag and i18n tag not 
> finding some resource bundles in the S2.1.1 branch but haven't had a 
> chance to investigate. There's several related issues in JIRA and I 
> recall something specifically about package-level properties.  I may 
> have an opportunity to investigate later today.  Does it find resources 
> in your action-properties or global properties?
> 
> cheers,
>  Jeromy Evans
> 
> mraible wrote:
>> I'm using 2.1.1-SNAPSHOT of the sitemesh and rest plugins.
>> FreeMarker/SiteMesh is working fine. However, I'm unable to use i18n tags
>> in
>> my decorator. In src/main/resources/com/company/app/package.properties, I
>> have:
>>
>> webapp.name=Foo
>> webapp.tagline=Bar
>>
>> In my decorators/default.ftl, I have:
>>
>> [@s.text name="webapp.name"/]
>>
>> And it renders:
>>
>> webapp.name
>>
>> Any idea why my Struts FreeMarker tag isn't being processed? I have the
>> following in my web.xml:
>>
>>     <filter-mapping>
>>         <filter-name>struts-cleanup</filter-name>
>>         <url-pattern>/*</url-pattern>
>>     </filter-mapping>
>>
>>     <filter-mapping>
>>         <filter-name>sitemesh</filter-name>
>>         <url-pattern>/*</url-pattern>
>>     </filter-mapping>
>>
>>     <filter-mapping>
>>         <filter-name>struts</filter-name>
>>         <url-pattern>/*</url-pattern>
>>     </filter-mapping>
>>
>> Thanks,
>>
>> Matt
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/i18n-Tags-in-FreeMarker-Decorator-for-SiteMesh-tp16599500p16601141.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: i18n Tags in FreeMarker Decorator for SiteMesh

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Hi Matt,

is it only the @s.text tag that isn't working?  eg. is @s.property working?

I've suspected there's a problem with the text tag and i18n tag not 
finding some resource bundles in the S2.1.1 branch but haven't had a 
chance to investigate. There's several related issues in JIRA and I 
recall something specifically about package-level properties.  I may 
have an opportunity to investigate later today.  Does it find resources 
in your action-properties or global properties?

cheers,
 Jeromy Evans

mraible wrote:
> I'm using 2.1.1-SNAPSHOT of the sitemesh and rest plugins.
> FreeMarker/SiteMesh is working fine. However, I'm unable to use i18n tags in
> my decorator. In src/main/resources/com/company/app/package.properties, I
> have:
>
> webapp.name=Foo
> webapp.tagline=Bar
>
> In my decorators/default.ftl, I have:
>
> [@s.text name="webapp.name"/]
>
> And it renders:
>
> webapp.name
>
> Any idea why my Struts FreeMarker tag isn't being processed? I have the
> following in my web.xml:
>
>     <filter-mapping>
>         <filter-name>struts-cleanup</filter-name>
>         <url-pattern>/*</url-pattern>
>     </filter-mapping>
>
>     <filter-mapping>
>         <filter-name>sitemesh</filter-name>
>         <url-pattern>/*</url-pattern>
>     </filter-mapping>
>
>     <filter-mapping>
>         <filter-name>struts</filter-name>
>         <url-pattern>/*</url-pattern>
>     </filter-mapping>
>
> Thanks,
>
> Matt
>   


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


Re: i18n Tags in FreeMarker Decorator for SiteMesh

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Zoran Avtarovski wrote:
> That¹s great news Jeromy. You don¹t know how much this will help us.
>
> As an aside, is there a timeline for the appearance of an official 2.1 beta
> build?
>
> Z.
>   
Hi Zoran.  I'm not really sure.  We tried to push forward and hit a 
small obstacle..  If nothing progresses I'll push again around the end 
of the month.

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


Re: i18n Tags in FreeMarker Decorator for SiteMesh

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
That¹s great news Jeromy. You don¹t know how much this will help us.

As an aside, is there a timeline for the appearance of an official 2.1 beta
build?

Z.
> 
> mraible wrote:
>> >
>> > Yes, that sound about right. My action is a POJO that only extends
>> > ModelDriven.
>> >   
> WW-2592 Struts2.1.1 now provides useful developer feedback for missing
> text resources:
>   - when a TextProvider was not found,
>   - when a message was not found,
>   - when the default value was used as an expression,
>   - when the default value was used as a literal string
> 
> eg.
> 
> WARNING:  [04:28.191] Could not find property [some]
> WARNING:  [04:28.211] The first TextProvider in the ValueStack
> (org.apache.struts2.TestAction) could not locate the message resource
> with key 'some.invalid.key.so.we.should.get.the.default.message'
> WARNING:  [04:28.211] The default value expression 'Sample Of Default
> Message' was evaluated and did not match a property.  The literal value
> 'Sample Of Default Message' will be used.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 



Re: i18n Tags in FreeMarker Decorator for SiteMesh

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
mraible wrote:
>
> Yes, that sound about right. My action is a POJO that only extends
> ModelDriven.
>   
WW-2592 Struts2.1.1 now provides useful developer feedback for missing 
text resources:
  - when a TextProvider was not found, 
  - when a message was not found,
  - when the default value was used as an expression,
  - when the default value was used as a literal string

eg.

WARNING:  [04:28.191] Could not find property [some]
WARNING:  [04:28.211] The first TextProvider in the ValueStack 
(org.apache.struts2.TestAction) could not locate the message resource 
with key 'some.invalid.key.so.we.should.get.the.default.message'
WARNING:  [04:28.211] The default value expression 'Sample Of Default 
Message' was evaluated and did not match a property.  The literal value 
'Sample Of Default Message' will be used.



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


Re: i18n Tags in FreeMarker Decorator for SiteMesh

Posted by mraible <ma...@raibledesigns.com>.


Jeromy Evans - Blue Sky Minds wrote:
> 
> mraible wrote:
>> I'm using 2.1.1-SNAPSHOT of the sitemesh and rest plugins.
>> FreeMarker/SiteMesh is working fine. However, I'm unable to use i18n tags
>> in
>> my decorator. In src/main/resources/com/company/app/package.properties, I
>> have:
>>
>> webapp.name=Foo
>> webapp.tagline=Bar
>>
>> In my decorators/default.ftl, I have:
>>
>> [@s.text name="webapp.name"/]
>>
>> And it renders:
>>
>> webapp.name
>>
>>   
> I've committed an update to 2.1.1 that may affect this.
> 
> However, my guess is that your action doesn't extend ActionSupport and 
> there's no alternate TextProvider available. In that case, the first 
> TextProvider found is the DefaultTextProvider which only serves 
> resources from the global resource bundle.  Does that sound right?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

Yes, that sound about right. My action is a POJO that only extends
ModelDriven.
-- 
View this message in context: http://www.nabble.com/i18n-Tags-in-FreeMarker-Decorator-for-SiteMesh-tp16599500p16646077.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: i18n Tags in FreeMarker Decorator for SiteMesh

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
mraible wrote:
> I'm using 2.1.1-SNAPSHOT of the sitemesh and rest plugins.
> FreeMarker/SiteMesh is working fine. However, I'm unable to use i18n tags in
> my decorator. In src/main/resources/com/company/app/package.properties, I
> have:
>
> webapp.name=Foo
> webapp.tagline=Bar
>
> In my decorators/default.ftl, I have:
>
> [@s.text name="webapp.name"/]
>
> And it renders:
>
> webapp.name
>
>   
I've committed an update to 2.1.1 that may affect this.

However, my guess is that your action doesn't extend ActionSupport and 
there's no alternate TextProvider available. In that case, the first 
TextProvider found is the DefaultTextProvider which only serves 
resources from the global resource bundle.  Does that sound right?

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