Created
March 12, 2009 21:41
-
-
Save masukomi/78303 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyAction extends ActionSupport implements TemplateMethodModel { | |
/*Your functionality here */ | |
/** | |
* when you need to display a localized piece of text in | |
* the ftl just use ${text("some.property.name")} | |
* there should be a package.properties or ClassName.properties | |
* file in the same source package directory as the Action that | |
* will be using them. There *is* a way to set a global properties file | |
* but I don't know the details. | |
* Obviously the text for other languages would be specified in files like | |
* package_en_US.properties | |
* @return an implementation of TemplateMethodModel which takes a | |
* one parameter method, the parameter is the name of the localized property | |
* you want to access. | |
*/ | |
public TemplateMethodModel getText(){ | |
return this; | |
} | |
public TemplateModel exec(List args) throws TemplateModelException { | |
if (args.size() != 1) { | |
throw new TemplateModelException("Wrong arguments"); | |
} | |
return new SimpleScalar(getText((String)args.get(0))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment