Class FreeMarkerWorker
java.lang.Object
org.apache.ofbiz.base.util.template.FreeMarkerWorker
FreeMarkerWorker - Freemarker Template Engine Utilities.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic freemarker.template.TemplateModel
static void
clearTemplateFromCache
(String templateLocation) createEnvironmentMap
(freemarker.core.Environment env) static Object
static String
static String
static freemarker.template.Configuration
Returns aConfiguration
instance initialized to OFBiz defaults.static freemarker.ext.beans.BeansWrapper
static void
getSiteParameters
(HttpServletRequest request, Map<String, Object> ctx) static freemarker.template.Template
getTemplate
(String templateLocation) Gets a Template instance from the template cache.static freemarker.template.Template
getTemplate
(String templateLocation, UtilCache<String, freemarker.template.Template> cache, freemarker.template.Configuration config) static <T> T
getWrappedObject
(String varName, freemarker.core.Environment env) Gets BeanModel from FreeMarker context and returns the object that it wraps.static freemarker.template.Configuration
makeConfiguration
(freemarker.ext.beans.BeansWrapper wrapper) static freemarker.template.Configuration
static void
static void
reloadValues
(Map<String, Object> context, Map<String, Object> saveValues, freemarker.core.Environment env) static void
removeValues
(Map<String, ?> context, String... removeKeyNames) static freemarker.core.Environment
renderTemplate
(freemarker.template.Template template, Map<String, Object> context, Appendable outWriter) Renders a Template instance.static void
renderTemplate
(String templateLocation, Map<String, Object> context, Appendable outWriter) Renders a template from a Reader.static void
renderTemplateFromString
(String templateName, String templateString, Map<String, Object> context, Appendable outWriter, long lastModificationTime, boolean useCache) static void
saveValues
(Map<String, Object> context, String[] saveKeyNames) static <T> T
-
Field Details
-
VERSION
public static final freemarker.template.Version VERSION
-
-
Method Details
-
getDefaultOfbizWrapper
public static freemarker.ext.beans.BeansWrapper getDefaultOfbizWrapper() -
newConfiguration
public static freemarker.template.Configuration newConfiguration() -
makeConfiguration
public static freemarker.template.Configuration makeConfiguration(freemarker.ext.beans.BeansWrapper wrapper) -
renderTemplate
public static void renderTemplate(String templateLocation, Map<String, Object> context, Appendable outWriter) throws freemarker.template.TemplateException, IOExceptionRenders a template from a Reader.- Parameters:
templateLocation
- A unique ID for this template - used for cachingcontext
- The context MapoutWriter
- The Writer to render to- Throws:
freemarker.template.TemplateException
IOException
-
renderTemplateFromString
public static void renderTemplateFromString(String templateName, String templateString, Map<String, Object> context, Appendable outWriter, long lastModificationTime, boolean useCache) throws freemarker.template.TemplateException, IOException- Throws:
freemarker.template.TemplateException
IOException
-
clearTemplateFromCache
-
renderTemplate
public static freemarker.core.Environment renderTemplate(freemarker.template.Template template, Map<String, Object> context, Appendable outWriter) throws freemarker.template.TemplateException, IOExceptionRenders a Template instance.- Parameters:
template
- A Template instancecontext
- The context MapoutWriter
- The Writer to render to- Throws:
freemarker.template.TemplateException
IOException
-
getDefaultOfbizConfig
public static freemarker.template.Configuration getDefaultOfbizConfig()Returns aConfiguration
instance initialized to OFBiz defaults. Client code should call this method instead of creating its ownConfiguration
instance. The instance returned by this method includes thecomponent://
resolver and the OFBiz custom transformations.- Returns:
- A
Configuration
instance.
-
getTemplate
Gets a Template instance from the template cache. If the Template instance isn't found in the cache, then one will be created.- Parameters:
templateLocation
- Location of the template - file path or URL- Throws:
IOException
-
getTemplate
public static freemarker.template.Template getTemplate(String templateLocation, UtilCache<String, freemarker.template.Template> cache, freemarker.template.Configuration config) throws IOException- Throws:
IOException
-
getArg
-
getArg
-
getWrappedObject
Gets BeanModel from FreeMarker context and returns the object that it wraps.- Parameters:
varName
- the name of the variable in the FreeMarker context.env
- the FreeMarker Environment
-
get
-
unwrap
-
createEnvironmentMap
-
saveContextValues
-
saveValues
-
reloadValues
-
removeValues
-
overrideWithArgs
-
getSiteParameters
-
autoWrap
public static freemarker.template.TemplateModel autoWrap(Object obj, freemarker.core.Environment env)
-