Package freemarker.ext.beans
package freemarker.ext.beans
The default object wrapper of FreeMarker uses
this to expose Java Beans and POJO-s to templates.
Most of the issues dealing with beans are handled by the BeansWrapper.wrap(Object)
and BeansWrapper.getStaticModels() methods. In normal cases, these are the only methods
you should use to turn an arbitrary Java object into a FreeMarker TemplateModel.
Additionally, you can manually create instance of any wrapper class using its constructors. Note, however that in
such cases you bypass the eventual model caching of the wrapper.
-
Interface SummaryInterfaceDescriptionReturned by
MemberAccessPolicy.forClass(Class).Implement this to restrict what class members (methods, fields, constructors) are accessible from templates.Used for customizing how the Java methods are visible from templates, viaBeansWrapper.setMethodAppearanceFineTuner(MethodAppearanceFineTuner).Marker interface useful when used together withMethodAppearanceFineTunerand such customizer objects, to indicate that it doesn't contain reference to theObjectWrapper(so beware with non-static inner classes) and can be and should be used in call introspection cache keys. -
Class SummaryClassDescriptionA class that will wrap an arbitrary array into
TemplateCollectionModelandTemplateSequenceModelinterfaces.A class that will wrap an arbitrary object intoTemplateHashModelinterface allowing calls to arbitrary property getters and invocation of accessible methods on the object from a template using theobject.footo access properties andobject.bar(arg1, arg2)to invoke methods on it.ObjectWrapperthat is able to expose the Java API of arbitrary Java objects.Used forMethodAppearanceFineTuner.process(freemarker.ext.beans.BeansWrapper.MethodAppearanceDecisionInput, freemarker.ext.beans.BeansWrapper.MethodAppearanceDecision)to store the results; see there.Used forMethodAppearanceFineTuner.process(freemarker.ext.beans.BeansWrapper.MethodAppearanceDecisionInput, freemarker.ext.beans.BeansWrapper.MethodAppearanceDecision)as input parameter; see there.Gets/creates aBeansWrappersingleton instance that's already configured as specified in the properties of this object; this is recommended over using theBeansWrapperconstructors.HoldsBeansWrapperconfiguration settings and defines their defaults.Blacklist-based member access policy, that is, members that are matched by the listing will not be accessible, all others will be.A class that will wrap instances ofBooleaninto aTemplateBooleanModel.A special case ofBeanModelthat can wrap Java collections and that implements theTemplateCollectionModelin order to be usable in a<#list>block.Wraps arbitrary subclass ofDateinto a reflective model.Member access policy to implement the default behavior that's mostly compatible with pre-2.3.30 versions, but is somewhat safer; it still can't provide safety in practice, if you allow untrusted users to edit templates! UseWhitelistMemberAccessPolicyif you need stricter control.A class that addsTemplateModelIteratorfunctionality to theEnumerationinterface implementers.This is used for wrapping objects that has no special treatment (unlikeMap-s,Collection-s,Number-s,Boolean-s, and some more, which have), hence they are just "generic" Java objects.A class that addsTemplateModelIteratorfunctionality to theIteratorinterface implementers.Legacy blacklist based member access policy, used only to keep old behavior, as it can't provide meaningful safety.A special case ofBeanModelthat adds implementation forTemplateMethodModelExon map objects that is a shortcut for theMap.get()method.Superclass for member-selector-list-based member access policies, likeWhitelistMemberAccessPolicy.A condition that matches some type members.Wraps arbitrary subclass ofNumberinto a reflective model.Wraps a set of same-name overloaded methods behindTemplateMethodModelinterface, like if it was a single method, chooses among them behind the scenes on call-time based on the argument values.A hash model that wraps a resource bundle.Model used byBeansWrapperwhensimpleMapWrappermode is enabled.A class that will wrap a reflected method call into aTemplateMethodModelinterface.Deprecated.Whitelist-based member access policy, that is, only members that are matched by the listing will be exposed. -
Enum Class SummaryEnum ClassDescriptionHow to show 0 argument non-void public methods to templates.
-
Exception SummaryExceptionDescriptionAn exception thrown when there is an attempt to access an invalid bean property when we are in a "strict bean" mode
-
Annotation Interfaces SummaryAnnotation InterfaceDescriptionIndicates that the the annotated member can be exposed to templates; if the annotated member will be actually exposed depends on the
ObjectWrapperin use, and how that was configured.
GenericObjectModelinstead, which implementsMethodCallAwareTemplateHashModel.