org.apache.struts.chain.servlet
Class TilesPreProcessor

java.lang.Object
  extended byorg.apache.struts.chain.servlet.TilesPreProcessor
All Implemented Interfaces:
org.apache.commons.chain.Command

public class TilesPreProcessor
extends java.lang.Object
implements org.apache.commons.chain.Command

Command class intended to perform responsibilities of the TilesRequestProcessor in Struts 1.1. Does not actually dispatch requests, but simply prepares the chain context for a later forward as appropriate. Should be added to a chain before something which would handle a conventional ForwardConfig.

This class will never have any effect on the chain unless a TilesDefinitionFactory can be found; however it does not consider the absence of a definition factory to be a fatal error; the command simply returns false and lets the chain continue.

To initialize the TilesDefinitionFactory, use org.apache.struts.chain.legacy.TilesPlugin. This class is a simple extension to org.apache.struts.tiles.TilesPlugin which simply does not interfere with your choice of RequestProcessor implementation.


Field Summary
private  java.lang.String forwardConfigKey
           
private  java.lang.String includeKey
           
private static org.apache.commons.logging.Log log
           
private  java.lang.String moduleConfigKey
           
 
Constructor Summary
TilesPreProcessor()
           
 
Method Summary
protected  void doInclude(org.apache.commons.chain.web.servlet.ServletWebContext swcontext, java.lang.String uri)
          Do an include of specified URI using a RequestDispatcher.
 boolean execute(org.apache.commons.chain.Context context)
          If the current ForwardConfig is using "tiles", perform necessary pre-processing to set up the TilesContext and substitute a new ForwardConfig which is understandable to a RequestDispatcher.
 java.lang.String getForwardConfigKey()
          Return the context attribute key under which the ForwardConfig for the currently selected application action is stored.
 java.lang.String getIncludeKey()
          Return the context attribute key under which the include uri for the currently selected application action is stored.
 void setForwardConfigKey(java.lang.String forwardConfigKey)
          Set the context attribute key under which the ForwardConfig for the currently selected application action is stored.
 void setIncludeKey(java.lang.String includeKey)
          Set the context attribute key under which the include uri for the currently selected application action is stored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

forwardConfigKey

private java.lang.String forwardConfigKey

includeKey

private java.lang.String includeKey

moduleConfigKey

private java.lang.String moduleConfigKey
Constructor Detail

TilesPreProcessor

public TilesPreProcessor()
Method Detail

getForwardConfigKey

public java.lang.String getForwardConfigKey()

Return the context attribute key under which the ForwardConfig for the currently selected application action is stored.


setForwardConfigKey

public void setForwardConfigKey(java.lang.String forwardConfigKey)

Set the context attribute key under which the ForwardConfig for the currently selected application action is stored.

Parameters:
forwardConfigKey - The new context attribute key

getIncludeKey

public java.lang.String getIncludeKey()

Return the context attribute key under which the include uri for the currently selected application action is stored.


setIncludeKey

public void setIncludeKey(java.lang.String includeKey)

Set the context attribute key under which the include uri for the currently selected application action is stored.

Parameters:
includeKey - The new context attribute key

execute

public boolean execute(org.apache.commons.chain.Context context)
                throws java.lang.Exception

If the current ForwardConfig is using "tiles", perform necessary pre-processing to set up the TilesContext and substitute a new ForwardConfig which is understandable to a RequestDispatcher.

Note that if the command finds a previously existing ComponentContext in the request, then it infers that it has been called from within another tile, so instead of changing the ForwardConfig in the chain Context, the command uses RequestDispatcher to include the tile, and returns true, indicating that the processing chain is complete.

Specified by:
execute in interface org.apache.commons.chain.Command
Parameters:
context - The Context for the current request
Returns:
false in most cases, but true if we determine that we're processing in "include" mode.
Throws:
java.lang.Exception

doInclude

protected void doInclude(org.apache.commons.chain.web.servlet.ServletWebContext swcontext,
                         java.lang.String uri)
                  throws java.io.IOException,
                         javax.servlet.ServletException

Do an include of specified URI using a RequestDispatcher.

Parameters:
swcontext - a chain servlet/web context
uri - Context-relative URI to include
Throws:
java.io.IOException
javax.servlet.ServletException


Copyright ? 2003 - Apache Software Foundation