TemplateEngineManagerpublic class TemplateEngineManager extends Object The TemplateEngineManager will return a template engine for the template |
Fields Summary |
---|
public static final String | DEFAULT_TEMPLATE_TYPE_CONFIG_KEY | public static final String | DEFAULT_TEMPLATE_TYPEThe default template extenstion is ftl . | Map | templateEngines | com.opensymphony.xwork2.inject.Container | container | String | defaultTemplateType |
Methods Summary |
---|
public TemplateEngine | getTemplateEngine(Template template, java.lang.String templateTypeOverride)Gets the TemplateEngine for the template name. If the template name has an extension (for instance foo.jsp), then
this extension will be used to look up the appropriate TemplateEngine. If it does not have an extension, it will
look for a Configuration setting "struts.ui.templateSuffix" for the extension, and if that is not set, it
will fall back to "ftl" as the default.
String templateType = DEFAULT_TEMPLATE_TYPE;
String templateName = template.toString();
if (templateName.indexOf(".") > 0) {
templateType = templateName.substring(templateName.indexOf(".") + 1);
} else if (templateTypeOverride !=null && templateTypeOverride.length() > 0) {
templateType = templateTypeOverride;
} else {
String type = defaultTemplateType;
if (type != null) {
templateType = type;
}
}
return templateEngines.get(templateType).create();
| public void | registerTemplateEngine(java.lang.String templateExtension, TemplateEngine templateEngine)Registers the given template engine.
Will add the engine to the existing list of known engines.
templateEngines.put(templateExtension, new EngineFactory() {
public TemplateEngine create() {
return templateEngine;
}
});
| public void | setContainer(com.opensymphony.xwork2.inject.Container container)
this.container = container;
Map<String,EngineFactory> map = new HashMap<String,EngineFactory>();
Set<String> prefixes = container.getInstanceNames(TemplateEngine.class);
for (String prefix : prefixes) {
map.put(prefix, new LazyEngineFactory(prefix));
}
this.templateEngines = Collections.unmodifiableMap(map);
| public void | setDefaultTemplateType(java.lang.String type)
this.defaultTemplateType = type;
|
|