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/ 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-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to