Package freemarker.template.utility
Class ObjectConstructor
java.lang.Object
freemarker.template.utility.ObjectConstructor
- All Implemented Interfaces:
TemplateMethodModel,TemplateMethodModelEx,TemplateModel
An object that you can make available in a template
to instantiate arbitrary beans-wrapped objects in a template.
Beware of this class's security implications. It allows
the instantiation of arbitrary objects and invoking
methods on them. Usage is something like:
myDataModel.put("objectConstructor", new ObjectConstructor());
And then from your FTL code:
<#assign aList = objectConstructor("java.util.ArrayList", 100)>
myDataModel.put("objectConstructor", new ObjectConstructor());
And then from your FTL code:
<#assign aList = objectConstructor("java.util.ArrayList", 100)>
-
Field Summary
Fields inherited from interface freemarker.template.TemplateModel
NOTHING -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ObjectConstructor
public ObjectConstructor()
-
-
Method Details
-
exec
Description copied from interface:TemplateMethodModelExExecutes the method call.- Specified by:
execin interfaceTemplateMethodModel- Specified by:
execin interfaceTemplateMethodModelEx- Parameters:
args- aListofTemplateModel-s, containing the arguments passed to the method. If the implementation absolutely wants to operate on POJOs, it can use the static utility methods in theDeepUnwrapclass to easily obtain them. However, unwrapping is not always possible (or not perfectly), and isn't always efficient, so it's recommended to use the originalTemplateModelvalue as much as possible.- Returns:
- the return value of the method, or
null. If the returned value does not implementTemplateModel, it will be automatically wrapped using theenvironment's object wrapper. - Throws:
TemplateModelException
-