struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Hjellming <>
Subject Struts2 w/freemarker and internationalization
Date Wed, 29 Feb 2012 18:01:41 GMT
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:


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;
             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 

So it seems the issue is Freemarker not accessing the TextProvider 

Other things I've tried:
- ${text('welcome.message')} -- same result
- having my action implement TemplateMethodModel per this link:  
but that didn't work either.

Can anyone provide any hints for how to get this very basic thing working?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message