org.apache.struts.tiles
Class TilesUtil

java.lang.Object
  |
  +--org.apache.struts.tiles.TilesUtil
Direct Known Subclasses:
DefinitionsUtil

public class TilesUtil
extends java.lang.Object

Class containing utilities for Tiles.


Field Summary
private static boolean implAlreadySet
          Flag to know if internal implementation have been set by the setter method
protected static org.apache.commons.logging.Log log
          Commons Logging instance.
protected static java.lang.String test
           
protected static TilesUtilInterface tilesUtilImpl
          The implementation of tilesUtilImpl
 
Constructor Summary
TilesUtil()
          Static constructor for tests
 
Method Summary
static DefinitionsFactory createDefinitionsFactory(javax.servlet.ServletContext servletContext, DefinitionsFactoryConfig factoryConfig)
          Create Definition factory from specified configuration object.
static void doForward(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext)
          Do a forward using request dispatcher.
static void doInclude(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext servletContext)
          Do an include using request dispatcher.
static DefinitionsFactory getDefaultDefinitionsFactory(javax.servlet.ServletContext servletContext)
           
static ComponentDefinition getDefinition(java.lang.String definitionName, javax.servlet.ServletRequest request, javax.servlet.ServletContext servletContext)
          Get a definition by its name.
static DefinitionsFactory getDefinitionsFactory(javax.servlet.ServletRequest request, javax.servlet.ServletContext servletContext)
          Get definition factory from appropriate servlet context.
static TilesUtilInterface getTilesUtil()
          Get the real implementation.
static void setTilesUtil(TilesUtilInterface tilesUtil)
          Set the real implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Commons Logging instance.


tilesUtilImpl

protected static TilesUtilInterface tilesUtilImpl
The implementation of tilesUtilImpl


test

protected static java.lang.String test

implAlreadySet

private static boolean implAlreadySet
Flag to know if internal implementation have been set by the setter method

Constructor Detail

TilesUtil

public TilesUtil()
Static constructor for tests

Method Detail

getTilesUtil

public static TilesUtilInterface getTilesUtil()
Get the real implementation.


setTilesUtil

public static void setTilesUtil(TilesUtilInterface tilesUtil)
Set the real implementation. This method should be called only once. Successive calls have no effect.


doForward

public static void doForward(java.lang.String uri,
                             javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             javax.servlet.ServletContext servletContext)
                      throws java.io.IOException,
                             javax.servlet.ServletException
Do a forward using request dispatcher. This method is used by the Tiles package anytime a forward is required.

Parameters:
uri - Uri or Definition name to forward
request - Current page request
response - Current page response
servletContext - Current servlet context
java.io.IOException
javax.servlet.ServletException

doInclude

public static void doInclude(java.lang.String uri,
                             javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             javax.servlet.ServletContext servletContext)
                      throws java.io.IOException,
                             javax.servlet.ServletException
Do an include using request dispatcher. This method is used by the Tiles package anytime an include is required.

Parameters:
uri - Uri or Definition name to forward
request - Current page request
response - Current page response
servletContext - Current servlet context
java.io.IOException
javax.servlet.ServletException

getDefaultDefinitionsFactory

public static DefinitionsFactory getDefaultDefinitionsFactory(javax.servlet.ServletContext servletContext)
Parameters:
servletContext - Current servlet context
Returns:
Definitions factory or null if not found.

getDefinitionsFactory

public static DefinitionsFactory getDefinitionsFactory(javax.servlet.ServletRequest request,
                                                       javax.servlet.ServletContext servletContext)
Get definition factory from appropriate servlet context.

Returns:
Definitions factory or null if not found.

createDefinitionsFactory

public static DefinitionsFactory createDefinitionsFactory(javax.servlet.ServletContext servletContext,
                                                          DefinitionsFactoryConfig factoryConfig)
                                                   throws DefinitionsFactoryException
Create Definition factory from specified configuration object. Create a ConfigurableDefinitionsFactory and initialize it with the configuration object. This later can contains the factory classname to use. Factory is made accessible from tags.

Fallback of several factory creation methods.

Parameters:
servletContext - Servlet Context passed to newly created factory.
factoryConfig - Configuration object passed to factory.
Returns:
newly created factory of type ConfigurableDefinitionsFactory.
Throws:
DefinitionsFactoryException - If an error occur while initializing factory

getDefinition

public static ComponentDefinition getDefinition(java.lang.String definitionName,
                                                javax.servlet.ServletRequest request,
                                                javax.servlet.ServletContext servletContext)
                                         throws FactoryNotFoundException,
                                                DefinitionsFactoryException
Get a definition by its name. First, retrieve definition factory, and then get requested definition. Throw appropriate exception if definition or definition factory is not found.

Parameters:
definitionName - Name of requested definition.
request - Current servelet request
servletContext - current servlet context
Throws:
FactoryNotFoundException - Can't find definition factory.
DefinitionsFactoryException - General error in factory while getting definition.
NoSuchDefinitionException - No definition found for specified name


Copyright 2000-2002 - Cedric Dumoulin and Apache Software Foundation