org.apache.tiles.freemarker.context
public final class FreeMarkerUtil extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMPOSE_STACK_ATTRIBUTE_NAME
The name of the attribute that holds the compose stack.
|
Modifier and Type | Method and Description |
---|---|
static void |
evaluateBody(TemplateDirectiveBody body)
Evaluates the body without rendering it.
|
static boolean |
getAsBoolean(TemplateModel model,
boolean defaultValue)
Unwraps a TemplateModel to extract a boolean.
|
static java.lang.Object |
getAsObject(TemplateModel model)
Unwraps a TemplateModel to extract an object.
|
static java.lang.String |
getAsString(TemplateModel model)
Unwraps a TemplateModel to extract a string.
|
static ArrayStack<java.lang.Object> |
getComposeStack(Environment env)
Returns the current compose stack, or creates a new one if not present.
|
static TilesContainer |
getContainer(Environment env,
java.lang.String key)
Returns a specific Tiles container.
|
static TilesContainer |
getCurrentContainer(Environment env)
Returns the current container that has been set, or the default one.
|
static HttpRequestHashModel |
getRequestHashModel(Environment env)
Returns the HTTP request hash model.
|
static ServletContextHashModel |
getServletContextHashModel(Environment env)
Returns the servlet context hash model.
|
static boolean |
isForceInclude(Environment env)
Returns true if forced include of the result is needed.
|
static java.lang.String |
renderAsString(TemplateDirectiveBody body)
Renders the body as a string.
|
static void |
setAttribute(Environment env,
java.lang.String name,
java.lang.Object obj,
java.lang.String scope)
Sets an attribute in the desired scope.
|
static void |
setCurrentContainer(Environment env,
java.lang.String key)
Sets the current container to use in web pages.
|
static void |
setCurrentContainer(Environment env,
TilesContainer container)
Sets the current container to use in web pages.
|
static void |
setForceInclude(Environment env,
boolean forceInclude)
Sets the option that enables the forced include of the response.
|
public static final java.lang.String COMPOSE_STACK_ATTRIBUTE_NAME
public static boolean isForceInclude(Environment env)
env
- The current FreeMarker environment.true
the include operation must be forced.public static void setForceInclude(Environment env, boolean forceInclude)
env
- The current FreeMarker environment.forceInclude
- If true
the include operation must be
forced.public static TilesContainer getContainer(Environment env, java.lang.String key)
env
- The current FreeMarker environment.key
- The key under which the container is stored. If null, the
default container will be returned.public static void setCurrentContainer(Environment env, java.lang.String key)
env
- The current FreeMarker environment.key
- The key under which the container is stored.public static void setCurrentContainer(Environment env, TilesContainer container)
env
- The current FreeMarker environment.container
- The container to use as the current container.public static TilesContainer getCurrentContainer(Environment env)
env
- The current FreeMarker environment.public static HttpRequestHashModel getRequestHashModel(Environment env)
env
- The current FreeMarker environment.public static ServletContextHashModel getServletContextHashModel(Environment env)
env
- The current FreeMarker environment.public static java.lang.String getAsString(TemplateModel model)
model
- The TemplateModel to unwrap.public static boolean getAsBoolean(TemplateModel model, boolean defaultValue)
model
- The TemplateModel to unwrap.defaultValue
- If the value is null, this value will be returned.public static java.lang.Object getAsObject(TemplateModel model)
model
- The TemplateModel to unwrap.public static void setAttribute(Environment env, java.lang.String name, java.lang.Object obj, java.lang.String scope)
env
- The FreeMarker current environment.name
- The name of the attribute.obj
- The value of the attribute.scope
- The scope. It can be page
, request
, session
, application
.public static ArrayStack<java.lang.Object> getComposeStack(Environment env)
env
- The current FreeMarker environment.public static void evaluateBody(TemplateDirectiveBody body) throws TemplateException, java.io.IOException
body
- The body to evaluate.TemplateException
- If something goes wrong during evaluation.java.io.IOException
- If something goes wrong during writing the result.public static java.lang.String renderAsString(TemplateDirectiveBody body) throws TemplateException, java.io.IOException
body
- The body to render.TemplateException
- If something goes wrong during evaluation.java.io.IOException
- If something goes wrong during writing the result.