Method from org.apache.tiles.jsp.context.JspUtil Detail: |
public static void evaluateFragment(JspFragment fragment) throws JspException, IOException {
if (fragment != null) {
fragment.invoke(null);
}
}
Evaluates the fragment (invokes it with a null Writer) if not null. |
public static String evaluateFragmentAsString(JspFragment fragment) throws JspException, IOException {
String body = null;
if (fragment != null) {
StringWriter writer = new StringWriter();
try {
fragment.invoke(writer);
} finally {
writer.close();
}
body = writer.toString();
}
return body;
}
Evaluates the fragment and returns its content as a string. |
public static ArrayStack<Object> getComposeStack(JspContext context) {
ArrayStack< Object > composeStack = (ArrayStack< Object >) context.getAttribute(
COMPOSE_STACK_ATTRIBUTE_NAME, PageContext.REQUEST_SCOPE);
if (composeStack == null) {
composeStack = new ArrayStack< Object >();
context.setAttribute(COMPOSE_STACK_ATTRIBUTE_NAME, composeStack,
PageContext.REQUEST_SCOPE);
}
return composeStack;
}
Returns the compose stack, that is used by the tags to compose
definitions, attributes, etc. |
public static TilesContainer getContainer(JspContext context) {
return getContainer(context, TilesAccess.CONTAINER_ATTRIBUTE);
}
Returns the default Tiles container. |
public static TilesContainer getContainer(JspContext context,
String key) {
if (key == null) {
key = TilesAccess.CONTAINER_ATTRIBUTE;
}
return (TilesContainer) context.getAttribute(key,
PageContext.APPLICATION_SCOPE);
}
Returns a specific Tiles container. |
public static TilesContainer getCurrentContainer(JspContext context) {
TilesContainer container = (TilesContainer) context.getAttribute(
ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
PageContext.REQUEST_SCOPE);
if (container == null) {
container = getContainer(context);
context.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
container, PageContext.REQUEST_SCOPE);
}
return container;
}
Returns the current container that has been set, or the default one. |
public static int getScope(String scopeName) throws TilesJspException {
if (scopeName == null) {
return PageContext.PAGE_SCOPE;
}
Integer scope = JspUtil.SCOPES.get(scopeName.toLowerCase());
if (scope == null) {
throw new TilesJspException("Unable to retrieve the scope "
+ scopeName);
}
return scope;
}
Converts the scope name into its corresponding PageContext constant value. |
public static boolean isForceInclude(JspContext context) {
Boolean retValue = (Boolean) context.getAttribute(
ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME,
PageContext.REQUEST_SCOPE);
return retValue != null && retValue.booleanValue();
}
Returns true if forced include of the result is needed. |
public static void setContainer(JspContext context,
TilesContainer container) {
setContainer(context, container, TilesAccess.CONTAINER_ATTRIBUTE);
}
Configures the default container to be used in the application. |
public static void setContainer(JspContext context,
TilesContainer container,
String key) {
Logger log = LoggerFactory.getLogger(ServletUtil.class);
if (key == null) {
key = TilesAccess.CONTAINER_ATTRIBUTE;
}
if (container == null) {
if (log.isInfoEnabled()) {
log.info("Removing TilesContext for context: " + context.getClass().getName());
}
context.removeAttribute(key, PageContext.APPLICATION_SCOPE);
}
if (container != null && log.isInfoEnabled()) {
log.info("Publishing TilesContext for context: " + context.getClass().getName());
}
context.setAttribute(key, container, PageContext.APPLICATION_SCOPE);
}
Configures the container to be used in the application. |
public static void setCurrentContainer(JspContext context,
String key) {
TilesContainer container = getContainer(context, key);
if (container != null) {
context.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
container, PageContext.REQUEST_SCOPE);
} else {
throw new NoSuchContainerException("The container with the key '"
+ key + "' cannot be found");
}
}
Sets the current container to use in web pages. |
public static void setCurrentContainer(JspContext context,
TilesContainer container) {
if (container != null) {
context.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME,
container, PageContext.REQUEST_SCOPE);
} else {
throw new NoSuchContainerException("The container cannot be null");
}
}
Sets the current container to use in web pages. |
public static void setForceInclude(JspContext context,
boolean forceInclude) {
Boolean retValue = Boolean.valueOf(forceInclude);
context.setAttribute(
ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME,
retValue, PageContext.REQUEST_SCOPE);
}
Sets the option that enables the forced include of the response. |