This project has retired. For details please refer to its Attic page.
FreeMarkerUtil (Tiles 2 2.2.2 API)

org.apache.tiles.freemarker.context
Class FreeMarkerUtil

Package class diagram package FreeMarkerUtil
java.lang.Object
  extended by org.apache.tiles.freemarker.context.FreeMarkerUtil

public final class FreeMarkerUtil
extends Object

Utilities for FreeMarker usage in Tiles.

Since:
2.2.0
Version:
$Rev: 797765 $ $Date: 2009-07-25 15:20:26 +0200 (sab, 25 lug 2009) $

Field Summary
static String COMPOSE_STACK_ATTRIBUTE_NAME
          The name of the attribute that holds the compose stack.
 
Method Summary
static void evaluateBody(freemarker.template.TemplateDirectiveBody body)
          Evaluates the body without rendering it.
static boolean getAsBoolean(freemarker.template.TemplateModel model, boolean defaultValue)
          Unwraps a TemplateModel to extract a boolean.
static Object getAsObject(freemarker.template.TemplateModel model)
          Unwraps a TemplateModel to extract an object.
static String getAsString(freemarker.template.TemplateModel model)
          Unwraps a TemplateModel to extract a string.
static ArrayStack<Object> getComposeStack(freemarker.core.Environment env)
          Returns the current compose stack, or creates a new one if not present.
static TilesContainer getContainer(freemarker.core.Environment env, String key)
          Returns a specific Tiles container.
static TilesContainer getCurrentContainer(freemarker.core.Environment env)
          Returns the current container that has been set, or the default one.
static freemarker.ext.servlet.HttpRequestHashModel getRequestHashModel(freemarker.core.Environment env)
          Returns the HTTP request hash model.
static freemarker.ext.servlet.ServletContextHashModel getServletContextHashModel(freemarker.core.Environment env)
          Returns the servlet context hash model.
static boolean isForceInclude(freemarker.core.Environment env)
          Returns true if forced include of the result is needed.
static String renderAsString(freemarker.template.TemplateDirectiveBody body)
          Renders the body as a string.
static void setAttribute(freemarker.core.Environment env, String name, Object obj, String scope)
          Sets an attribute in the desired scope.
static void setCurrentContainer(freemarker.core.Environment env, String key)
          Sets the current container to use in web pages.
static void setCurrentContainer(freemarker.core.Environment env, TilesContainer container)
          Sets the current container to use in web pages.
static void setForceInclude(freemarker.core.Environment env, boolean forceInclude)
          Sets the option that enables the forced include of the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPOSE_STACK_ATTRIBUTE_NAME

public static final String COMPOSE_STACK_ATTRIBUTE_NAME
The name of the attribute that holds the compose stack.

See Also:
Constant Field Values
Method Detail

isForceInclude

public static boolean isForceInclude(freemarker.core.Environment env)
Returns true if forced include of the result is needed.

Parameters:
env - The current FreeMarker environment.
Returns:
If true the include operation must be forced.
Since:
2.2.0

setForceInclude

public static void setForceInclude(freemarker.core.Environment env,
                                   boolean forceInclude)
Sets the option that enables the forced include of the response.

Parameters:
env - The current FreeMarker environment.
forceInclude - If true the include operation must be forced.
Since:
2.2.0

getContainer

public static TilesContainer getContainer(freemarker.core.Environment env,
                                          String key)
Returns a specific Tiles container.

Parameters:
env - The current FreeMarker environment.
key - The key under which the container is stored. If null, the default container will be returned.
Returns:
The requested Tiles container.
Since:
2.2.0

setCurrentContainer

public static void setCurrentContainer(freemarker.core.Environment env,
                                       String key)
Sets the current container to use in web pages.

Parameters:
env - The current FreeMarker environment.
key - The key under which the container is stored.
Since:
2.2.0

setCurrentContainer

public static void setCurrentContainer(freemarker.core.Environment env,
                                       TilesContainer container)
Sets the current container to use in web pages.

Parameters:
env - The current FreeMarker environment.
container - The container to use as the current container.
Since:
2.2.0

getCurrentContainer

public static TilesContainer getCurrentContainer(freemarker.core.Environment env)
Returns the current container that has been set, or the default one.

Parameters:
env - The current FreeMarker environment.
Returns:
The current Tiles container to use in web pages.
Since:
2.2.0

getRequestHashModel

public static freemarker.ext.servlet.HttpRequestHashModel getRequestHashModel(freemarker.core.Environment env)
Returns the HTTP request hash model.

Parameters:
env - The current FreeMarker environment.
Returns:
The request hash model.
Since:
2.2.0

getServletContextHashModel

public static freemarker.ext.servlet.ServletContextHashModel getServletContextHashModel(freemarker.core.Environment env)
Returns the servlet context hash model.

Parameters:
env - The current FreeMarker environment.
Returns:
The servlet context hash model.
Since:
2.2.0

getAsString

public static String getAsString(freemarker.template.TemplateModel model)
Unwraps a TemplateModel to extract a string.

Parameters:
model - The TemplateModel to unwrap.
Returns:
The unwrapped string.
Since:
2.2.0

getAsBoolean

public static boolean getAsBoolean(freemarker.template.TemplateModel model,
                                   boolean defaultValue)
Unwraps a TemplateModel to extract a boolean.

Parameters:
model - The TemplateModel to unwrap.
defaultValue - If the value is null, this value will be returned.
Returns:
The unwrapped boolean.
Since:
2.2.0

getAsObject

public static Object getAsObject(freemarker.template.TemplateModel model)
Unwraps a TemplateModel to extract an object.

Parameters:
model - The TemplateModel to unwrap.
Returns:
The unwrapped object.
Since:
2.2.0

setAttribute

public static void setAttribute(freemarker.core.Environment env,
                                String name,
                                Object obj,
                                String scope)
Sets an attribute in the desired scope.

Parameters:
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.
Since:
2.2.0

getComposeStack

public static ArrayStack<Object> getComposeStack(freemarker.core.Environment env)
Returns the current compose stack, or creates a new one if not present.

Parameters:
env - The current FreeMarker environment.
Returns:
The compose stack.
Since:
2.2.0

evaluateBody

public static void evaluateBody(freemarker.template.TemplateDirectiveBody body)
                         throws freemarker.template.TemplateException,
                                IOException
Evaluates the body without rendering it.

Parameters:
body - The body to evaluate.
Throws:
freemarker.template.TemplateException - If something goes wrong during evaluation.
IOException - If something goes wrong during writing the result.
Since:
2.2.0

renderAsString

public static String renderAsString(freemarker.template.TemplateDirectiveBody body)
                             throws freemarker.template.TemplateException,
                                    IOException
Renders the body as a string.

Parameters:
body - The body to render.
Returns:
The rendered string.
Throws:
freemarker.template.TemplateException - If something goes wrong during evaluation.
IOException - If something goes wrong during writing the result.
Since:
2.2.0


Copyright © 2001-2010 Apache Software Foundation. All Rights Reserved.