Uses of Class
freemarker.template.TemplateModelException
Packages that use TemplateModelException
Package
Description
The seldom used or advanced parts of the fundamental FreeMarker API, compared to
freemarker.template
.Debugging API; experimental status, might change!
This is to support debugging in IDE-s.
The default object wrapper of FreeMarker uses
this to expose Java Beans and POJO-s to templates.
Exposes DOM XML nodes to templates as easily traversable trees;
see in the Manual.
Deprecated, use W3C DOM (
freemarker.ext.dom
) instead;
Exposes JDOM XML nodes to templates.
Classes for two-way FreeMarker-JSP integration.
Exposes Jython objects to templates.
Exposes Rhino (ECMAScript) objects to templates.
Servlet for legacy "Model 2" frameworks that allows using FreeMarker
templates instead of JSP as the MVC View
(see in the Manual).
Deprecated, use W3C DOM with
freemarker.ext.dom
instead;
Exposes XML from DOM, dom4j or JDOM nodes, uniformly.The fundamental, most commonly used API-s of FreeMarker;
start with
Configuration
(see also the
Getting Started in the Manual.)Various classes used by core FreeMarker code but might be useful outside of it too.
-
Uses of TemplateModelException in freemarker.core
Methods in freemarker.core that throw TemplateModelExceptionModifier and TypeMethodDescriptionEnvironment.__getitem__
(String key) A hook that Jython uses.final MO
abstract MO
Returns aTemplateMarkupOutputModel
that contains the content of bothTemplateMarkupOutputModel
objects concatenated.CombinedMarkupOutputFormat.escapePlainText
(String plainTextContent) abstract String
MarkupOutputFormat.escapePlainText
(String plainTextContent) Should give the same result asMarkupOutputFormat.fromPlainTextByEscaping(String)
and thenMarkupOutputFormat.getMarkupString(TemplateMarkupOutputModel)
, but the implementation may uses a more efficient solution.TemplateDateFormat.format
(TemplateDateModel dateModel) Formats the model to markup instead of to plain text if the result markup will be more than just plain text escaped, otherwise falls back to formatting to plain text.TemplateNumberFormat.format
(TemplateNumberModel numberModel) Formats the model to markup instead of to plain text if the result markup will be more than just plain text escaped, otherwise falls back to formatting to plain text.abstract String
TemplateDateFormat.formatToPlainText
(TemplateDateModel dateModel) abstract String
TemplateNumberFormat.formatToPlainText
(TemplateNumberModel numberModel) final MO
CommonMarkupOutputFormat.fromMarkup
(String markupText) abstract MO
MarkupOutputFormat.fromMarkup
(String markupText) Wraps aString
that's already markup toTemplateMarkupOutputModel
interface, to indicate its format.final MO
CommonMarkupOutputFormat.fromPlainTextByEscaping
(String textToEsc) abstract MO
MarkupOutputFormat.fromPlainTextByEscaping
(String textToEsc) Converts aString
that's assumed to be plain text toTemplateMarkupOutputModel
, by escaping any special characters in the plain text.Environment.getDataModelOrSharedVariable
(String name) Returns the variable from the data-model, or if it's not there, then from the Configuration.setSharedVariables(Map) shared variables}Environment.getGlobalVariable
(String name) Returns the globally visible variable of the given name, ornull
.Environment.getKnownVariableNames()
Returns a set of variable names that are known at the time of call.Environment.getLocalVariable
(String name) Returns the loop or macro local variable corresponding to this variable name.final String
CommonMarkupOutputFormat.getMarkupString
(MO mo) abstract String
MarkupOutputFormat.getMarkupString
(MO mo) Returns the content as markup text; nevernull
.protected int
DefaultTruncateBuiltinAlgorithm.getMTerminatorLength
(TemplateMarkupOutputModel<?> mTerminator) Returns the (estimated) length of the argument terminator.protected boolean
DefaultTruncateBuiltinAlgorithm.getMTerminatorRemovesDots
(TemplateMarkupOutputModel terminator) Same asDefaultTruncateBuiltinAlgorithm.getTerminatorRemovesDots(String)
, but invoked for a markup terminator.static Date
TemplateFormatUtil.getNonNullDate
(TemplateDateModel dateModel) Utility method to extract theDate
from anTemplateDateModel
, and throwTemplateModelException
with a standard error message if that'snull
.static Number
TemplateFormatUtil.getNonNullNumber
(TemplateNumberModel numberModel) Utility method to extract theNumber
from anTemplateNumberModel
, and throwsTemplateModelException
with a standard error message if that'snull
.final String
CommonMarkupOutputFormat.getSourcePlainText
(MO mo) abstract String
MarkupOutputFormat.getSourcePlainText
(MO mo) If thisTemplateMarkupOutputModel
was created withMarkupOutputFormat.fromPlainTextByEscaping(String)
, it returns the original plain text, otherwise it returnsnull
.protected boolean
DefaultTruncateBuiltinAlgorithm.getTerminatorRemovesDots
(String terminator) Tells if the dots touched by the terminator text should be removed.Environment.getVariable
(String name) Returns the variable that is visible in this context, ornull
if the variable is not found.boolean
abstract boolean
Returns if the markup is empty (0 length).boolean
CombinedMarkupOutputFormat.isLegacyBuiltInBypassed
(String builtInName) abstract boolean
MarkupOutputFormat.isLegacyBuiltInBypassed
(String builtInName) Tells if a string built-in that can't handle aTemplateMarkupOutputModel
left hand operand can bypass this object as is.protected abstract MO
CommonMarkupOutputFormat.newTemplateMarkupOutputModel
(String plainTextContent, String markupContent) Creates a newCommonTemplateMarkupOutputModel
that's bound to thisOutputFormat
instance.void
abstract void
final void
void
abstract void
Equivalent to callingMarkupOutputFormat.fromPlainTextByEscaping(String)
and thenMarkupOutputFormat.output(TemplateMarkupOutputModel, Writer)
, but the implementation may uses a more efficient solution.abstract void
Prints the parameter model to the output.void
void
void
-
Uses of TemplateModelException in freemarker.debug
Methods in freemarker.debug that throw TemplateModelExceptionModifier and TypeMethodDescriptionDebugModel.get
(int index) DebugModel.get
(int fromIndex, int toIndex) boolean
DebugModel.getAsBoolean()
DebugModel.getAsDate()
DebugModel.getAsNumber()
DebugModel.getAsString()
DebugModel.getCollection()
int
DebugModel.getDateType()
String[]
DebugModel.keys()
int
DebugModel.size()
-
Uses of TemplateModelException in freemarker.ext.beans
Subclasses of TemplateModelException in freemarker.ext.beansModifier and TypeClassDescriptionclass
An exception thrown when there is an attempt to access an invalid bean property when we are in a "strict bean" modeMethods in freemarker.ext.beans that throw TemplateModelExceptionModifier and TypeMethodDescriptionThe first argument is used as a key to call the map's get method.Invokes the method, passing it the arguments from the list.Takes first argument as a resource key, looks up a string in resource bundle with this key, then applies a MessageFormat.format on the string with the rest of the arguments.Invokes the method, passing it the arguments from the list.ArrayModel.get
(int index) Uses Beans introspection to locate a property or method with name matching the key name.CollectionModel.get
(int index) Retrieves the i-th object from the collection, wrapped as a TemplateModel.OverloadedMethodsModel.get
(int index) SimpleMethodModel.get
(int index) BeanModel.getAPI()
SimpleMapModel.getAPI()
protected TemplateModel
BeanModel.invokeGenericGet
(Map classInfo, Class<?> clazz, String key) protected TemplateModel
MapModel.invokeGenericGet
(Map keyMap, Class clazz, String key) Overridden to invoke the generic get method by casting to Map instead of through reflection - should yield better performance.protected TemplateModel
ResourceBundleModel.invokeGenericGet
(Map keyMap, Class clazz, String key) Overridden to invoke the getObject method of the resource bundle.protected TemplateModel
BeansWrapper.invokeMethod
(Object object, Method method, Object[] args) Invokes the specified method, wrapping the return value.EnumerationModel.iterator()
This allows the enumeration to be used in a <#list> block.IteratorModel.iterator()
This allows the iterator to be used in a <#list> block.BeansWrapper.newInstance
(Class<?> clazz, List arguments) Creates a new instance of the specified class using the method call logic of this object wrapper for calling the constructor.EnumerationModel.next()
Calls underlyingEnumeration.nextElement()
and wraps the result.IteratorModel.next()
Calls underlyingIterator.next()
and wraps the result.protected TemplateModel
Reads the specified field, returns its value asTemplateModel
.int
OverloadedMethodsModel.size()
int
SimpleMethodModel.size()
BeansWrapper.tryUnwrapTo
(TemplateModel model, Class<?> targetClass) protected Object
BeanModel.unwrap
(TemplateModel model) BeansWrapper.unwrap
(TemplateModel model) Attempts to unwrap a model into underlying object.BeansWrapper.unwrap
(TemplateModel model, Class<?> targetClass) Attempts to unwrap a model into an object of the desired class.BeanModel.values()
protected TemplateModel
Wraps the object with a template model that is most specific for the object's class. -
Uses of TemplateModelException in freemarker.ext.dom
Methods in freemarker.ext.dom that throw TemplateModelExceptionModifier and TypeMethodDescriptionXPathSupport.executeQuery
(Object context, String xpathQuery) NodeModel.getNextSibling()
final String
NodeModel.getNodeType()
NodeModel.getPreviousSibling()
-
Uses of TemplateModelException in freemarker.ext.jdom
Methods in freemarker.ext.jdom that throw TemplateModelExceptionModifier and TypeMethodDescriptionDeprecated.Applies an XPath expression to the node list and returns the resulting node list.NodeListModel.get
(int i) Deprecated.Retrieves the i-th element of the node list.Deprecated.Provides node list traversal as well as special functions: filtering by name, filtering by node type, shallow-copying, and duplicate removal.NodeListModel.getAsString()
Deprecated.This method returns the string resulting from concatenation of string representations of its nodes. -
Uses of TemplateModelException in freemarker.ext.jsp
Methods in freemarker.ext.jsp that throw TemplateModelExceptionModifier and TypeMethodDescriptionRetrieves a JSP tag library identified by an URI. -
Uses of TemplateModelException in freemarker.ext.jython
Methods in freemarker.ext.jython that throw TemplateModelExceptionModifier and TypeMethodDescriptionCallsPyObject.__findattr__(java.lang.String)
, then if it returns null callsPyObject.__finditem__(java.lang.String)
.JythonSequenceModel.get
(int index) ReturnsPyObject.__finditem__(int)
.boolean
JythonModel.getAsBoolean()
Returns the value ofPyObject.__nonzero__()
.JythonNumberModel.getAsNumber()
Returns eitherPyObject.__tojava__(java.lang.Class)
withNumber
.class as argument.JythonModel.getAsString()
Returns the value ofObject.toString()
.boolean
JythonModel.isEmpty()
ReturnsPyObject.__len__()
== 0
.JythonHashModel.keys()
Returns eitherobject.__findattr__("keys").__call__()
orobject.__findattr__("keySet").__call__()
.int
JythonHashModel.size()
ReturnsPyObject.__len__()
.int
JythonSequenceModel.size()
ReturnsPyObject.__len__()
.org.python.core.PyObject
JythonWrapper.unwrap
(TemplateModel model) Coerces a template model into aPyObject
.JythonHashModel.values()
Returnsobject.__findattr__("values").__call__()
. -
Uses of TemplateModelException in freemarker.ext.rhino
Methods in freemarker.ext.rhino that throw TemplateModelException -
Uses of TemplateModelException in freemarker.ext.servlet
Methods in freemarker.ext.servlet that throw TemplateModelExceptionModifier and TypeMethodDescriptionprotected TemplateModel
FreemarkerServlet.createModel
(ObjectWrapper objectWrapper, javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) protected TaglibFactory
FreemarkerServlet.createTaglibFactory
(ObjectWrapper objectWrapper, javax.servlet.ServletContext servletContext) Called to create theTaglibFactory
once per servlet context.boolean
HttpSessionHashModel.isEmpty()
-
Uses of TemplateModelException in freemarker.ext.xml
Methods in freemarker.ext.xml that throw TemplateModelExceptionModifier and TypeMethodDescriptionDeprecated.Evaluates an XPath expression on XML nodes in this model.Deprecated.Returns a new NodeListModel containing the nodes that result from applying an operator to this model's nodes.NodeListModel.getAsString()
Deprecated.Returns the string representation of the wrapped nodes.NodeListModel.getChildNodes()
Deprecated.NodeListModel.getNodeName()
Deprecated.NodeListModel.getNodeNamespace()
Deprecated.NodeListModel.getNodeType()
Deprecated.NodeListModel.getParentNode()
Deprecated. -
Uses of TemplateModelException in freemarker.template
Methods in freemarker.template that throw TemplateModelExceptionModifier and TypeMethodDescriptionint
TransformControl.afterBody()
Called after the body has been evaluated.boolean
DefaultNonListCollectionAdapter.contains
(TemplateModel item) Deprecated.Executes the method call.Executes the method call.DefaultListAdapter.get
(int index) SimpleSequence.get
(int index) Returns the item at the specified index of the list.Gets a TemplateModel from the hash.TemplateSequenceModel.get
(int index) Retrieves the i-th template model in this sequence.DefaultEnumerationAdapter.getAPI()
DefaultIterableAdapter.getAPI()
DefaultIteratorAdapter.getAPI()
DefaultListAdapter.getAPI()
DefaultMapAdapter.getAPI()
DefaultNonListCollectionAdapter.getAPI()
TemplateModelWithAPISupport.getAPI()
Returns the model that exposes the (Java) API of the value.boolean
TemplateBooleanModel.getAsBoolean()
TemplateDateModel.getAsDate()
Returns the date value.TemplateNumberModel.getAsNumber()
Returns the numeric value.LocalizedString.getAsString()
TemplateScalarModel.getAsString()
Returns theString
representation of this model.TemplateNodeModel.getChildNodes()
TemplateHashModelEx2.KeyValuePair.getKey()
abstract String
LocalizedString.getLocalizedString
(Locale locale) ResourceBundleLocalizedString.getLocalizedString
(Locale locale) TemplateNodeModelEx.getNextSibling()
TemplateNodeModel.getNodeName()
TemplateNodeModel.getNodeNamespace()
TemplateNodeModel.getNodeType()
TemplateNodeModel.getParentNode()
TemplateNodeModelEx.getPreviousSibling()
TemplateHashModelEx2.KeyValuePair.getValue()
Returns a writer that will be used by the engine to feed the transformation input to the transform.protected TemplateModel
DefaultObjectWrapper.handleUnknownType
(Object obj) Called for an object that isn't considered to be of a "basic" Java type, like for an application specific type, or for a W3C DOM node.protected TemplateModel
SimpleObjectWrapper.handleUnknownType
(Object obj) Called if a type other than the simple ones we know about is passed in.boolean
TemplateHashModelEx2.KeyValuePairIterator.hasNext()
Similar toIterator.hasNext()
.boolean
TemplateModelIterator.hasNext()
boolean
TemplateCollectionModelEx.isEmpty()
Returns if the collection contains any elements.boolean
TemplateHashModel.isEmpty()
DefaultEnumerationAdapter.iterator()
DefaultIterableAdapter.iterator()
DefaultIteratorAdapter.iterator()
DefaultNonListCollectionAdapter.iterator()
TemplateCollectionModel.iterator()
Retrieves a template model iterator that is used to iterate over the elements in this collection.TemplateHashModelEx.keys()
TemplateHashModelEx2.keyValuePairIterator()
TemplateHashModelEx2.KeyValuePairIterator.next()
Similar toIterator.next()
.TemplateModelIterator.next()
Returns the next model.int
TransformControl.onStart()
Called before the body is evaluated for the first time.void
Configuration.setAllSharedVariables
(TemplateHashModelEx hash) Adds all object in the hash as shared variable to the configuration; it's like doing severalConfiguration.setSharedVariable(String, Object)
calls, one for each hash entry.void
Configuration.setSharedVariable
(String name, Object value) Adds shared variable to the configuration; It usesConfigurable.getObjectWrapper()
to wrap thevalue
, so it's important that the object wrapper is set before this.void
Configuration.setSharedVariables
(Map<String, ?> map) Replaces all shared variables (removes all previously added ones).void
Configuration.setSharedVaribles
(Map map) Deprecated.int
DefaultListAdapter.size()
int
TemplateCollectionModelEx.size()
Returns the number items in this collection, orInteger.MAX_VALUE
, if there are more thanInteger.MAX_VALUE
items.int
TemplateHashModelEx.size()
int
TemplateSequenceModel.size()
SimpleSequence.toList()
Deprecated.No replacement exists; not a reliable way of getting back the original list elemnts.SimpleHash.toMap()
Note that this method creates and returns a deep-copy of the underlying hash used internally.ObjectWrapperAndUnwrapper.tryUnwrapTo
(TemplateModel tm, Class<?> targetClass) Attempts to unwrap aTemplateModel
to a plain Java object that's the instance of the given class (or isnull
).ObjectWrapperAndUnwrapper.unwrap
(TemplateModel tm) Unwraps aTemplateModel
to a plain Java object.TemplateHashModelEx.values()
Wraps the parameter object toTemplateModel
interface(s).Makes aTemplateModel
out of a non-TemplateModel
object, usually by "wrapping" it into aTemplateModel
implementation that delegates to the original object.protected final TemplateModel
Wraps the passed object into a template model using this object's object wrapper.Constructors in freemarker.template that throw TemplateModelExceptionModifierConstructorDescriptionConstructs a simple sequence from the passed collection model, which shouldn't be added to later. -
Uses of TemplateModelException in freemarker.template.utility
Methods in freemarker.template.utility that throw TemplateModelExceptionModifier and TypeMethodDescriptionExecutes a method call.Deprecated.static final TemplateHashModelEx2.KeyValuePairIterator
TemplateModelUtils.getKeyValuePairIterator
(TemplateHashModelEx hash) TemplateModelUtils.TemplateHashModelExKeyValuePairIterator
that even works for a non-TemplateHashModelEx2
TemplateHashModelEx
.Deprecated.static Object
DeepUnwrap.permissiveUnwrap
(TemplateModel model) Same asDeepUnwrap.unwrap(TemplateModel)
, but it doesn't throw exception if it doesn't know how to unwrap the model, but rather returns it as-is.static Object
DeepUnwrap.premissiveUnwrap
(TemplateModel model) Deprecated.the name of this method is mistyped.static Object
DeepUnwrap.unwrap
(TemplateModel model) UnwrapsTemplateModel
-s recursively.Wraps an object to aTemplateModel
that exposes the object's "native" (usually, Java) API.static TemplateHashModel
TemplateModelUtils.wrapAsHashUnion
(ObjectWrapper objectWrapper, Object... hashLikeObjects) Same asTemplateModelUtils.wrapAsHashUnion(ObjectWrapper, List)
, but uses a varargs parameter instead of aList
.static TemplateHashModel
TemplateModelUtils.wrapAsHashUnion
(ObjectWrapper objectWrapper, List<?> hashLikeObjects) Creates aTemplateHashModel
that is the union of the hash-like objects passed in as argument.
Configuration.setSharedVariables(Map)
instead.