freemarker.template.utility
Class ObjectConstructor

java.lang.Object
  extended by freemarker.template.utility.ObjectConstructor
All Implemented Interfaces:
TemplateMethodModel, TemplateMethodModelEx, TemplateModel

public class ObjectConstructor
extends java.lang.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)>


Field Summary
 
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
 
Constructor Summary
ObjectConstructor()
           
 
Method Summary
 java.lang.Object exec(java.util.List args)
          Executes a method call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectConstructor

public ObjectConstructor()
Method Detail

exec

public java.lang.Object exec(java.util.List args)
                      throws TemplateModelException
Description copied from interface: TemplateMethodModel
Executes a method call. All arguments passed to the method call are treated as TemplateScalarModels, and evaluated to Strings before being passed. If some of the passed arguments is not a scalar, an exception will occur and the method will not be called. If your method would like to act on actual data model objects instead of on their String representations, implement the TemplateMethodModelEx instead.

Specified by:
exec in interface TemplateMethodModel
Parameters:
args - a List of String objects containing the values of the arguments passed to the method.
Returns:
the TemplateModel produced by the method, or null.
Throws:
TemplateModelException