struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josep GarcĂ­a <jgar...@isigma.es>
Subject Re: Struts2 w/freemarker and internationalization
Date Wed, 29 Feb 2012 18:16:53 GMT
Try with:

<p><@s.text name="welcome.message"/></p>

Cheers,
Josep


2012/2/29 Tom Hjellming <thjellming@gmail.com>

> I'm trying to internationalize a simple Struts2-based webapp that uses
> Freemarker as the view technology.  The usage of freemarker templating
> pulling values from the Action object is working fine.
>
> But when I try to leverage Struts2's TextProvider capability via
> getText(), it doesn't work.
>
> My action extends ActionSupport which implements the TextProvider
> interface.
>
> My freemarker template file contains this:
>
> <p>${getText('welcome.message'**)}</p>
>
> My properties file is:  {MyActionName}.properties and located in same
> directory as the java source.  It contains:
>
> welcome.message=The Welcome message goes here
>
> But I get the dreaded freemarker.core.**InvalidReferenceException:
>  Expression getText is undefined.
>
> To test that the resource bundle can be located, I inserted code in my
> Action's execute():
>        String res;
>        try
>        {
>            res = getText("welcome.message", "default welcome msg from
> execute() method");
>        }
>        catch (Throwable e)
>        {
>            res = null;
>        }
>
> With the debugger, I see the res is being set to 'The Welcome message goes
> here' -- which tells me the ResourceBundle is working inside TextProvider.
>
> So it seems the issue is Freemarker not accessing the TextProvider
> interface.
>
> Other things I've tried:
> - ${text('welcome.message')} -- same result
> - having my action implement TemplateMethodModel per this link:
> http://weblog.masukomi.org/**2009/03/12/localization-for-**
> struts-freemarker-users/<http://weblog.masukomi.org/2009/03/12/localization-for-struts-freemarker-users/>
but that didn't work either.
>
> Can anyone provide any hints for how to get this very basic thing working?
>
> thanks,
> Tom
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<user-unsubscribe@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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