freemarker.template.utility
Class ObjectConstructor
java.lang.Object
freemarker.template.utility.ObjectConstructor
- All Implemented Interfaces:
- TemplateMethodModel, TemplateMethodModelEx, TemplateModel
public class ObjectConstructor
- extends Object
- implements TemplateMethodModelEx
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)>
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ObjectConstructor
public ObjectConstructor()
exec
public Object exec(List args)
throws TemplateModelException
- Description copied from interface:
TemplateMethodModelEx
- Executes a method call.
- Specified by:
exec
in interface TemplateMethodModel
- Specified by:
exec
in interface TemplateMethodModelEx
- Parameters:
args
- a List of TemplateModel
objects
containing the values of the arguments passed to the method. If the
implementation wishes to operate on POJOs that might be underlying the
models, it can use the static utility methods in the DeepUnwrap
class to easily obtain them.
- Returns:
- the return value of the method, or null. If the returned value
does not implement
TemplateModel
, it will be automatically
wrapped using the environment
object wrapper
.
- Throws:
TemplateModelException