org.apache.struts.taglib.tiles
Class InsertTag

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--org.apache.struts.taglib.tiles.DefinitionTagSupport
              |
              +--org.apache.struts.taglib.tiles.InsertTag
All Implemented Interfaces:
ComponentConstants, javax.servlet.jsp.tagext.IterationTag, PutListTagParent, PutTagParent, java.io.Serializable, javax.servlet.jsp.tagext.Tag
Direct Known Subclasses:
GetTag

public class InsertTag
extends DefinitionTagSupport
implements PutTagParent, ComponentConstants, PutListTagParent

This is the tag handler for <template:insert>, which includes a template. The tag's body content consists of <template:put> tags, which are accessed by <template:get> in the template.

Version:
$Revision: 1.5 $ $Date: 2002/10/28 05:15:48 $
Author:
David Geary, Cedric Dumoulin
See Also:
Serialized Form

Nested Class Summary
protected  class InsertTag.DirectStringHandler
          Handle insert direct string.
protected  class InsertTag.InsertHandler
          Real handler, after attribute resolution.
protected static interface InsertTag.TagHandler
          Inner Interface Sub handler for tag.
 
Field Summary
protected  java.lang.String attribute
          Name of attribute from which to read page name to include
protected  java.lang.String beanName
          Name of bean used as entity to include
protected  java.lang.String beanProperty
          Name of bean property, if any
protected  java.lang.String beanScope
          Scope of bean, if any
protected  ComponentContext cachedCurrentContext
          Current component context
protected  java.lang.String definitionName
          Name of component instance to include
protected  boolean flush
          Flush attribute value
protected  boolean isErrorIgnored
          Are errors ignored.
protected static org.apache.commons.logging.Log log
          Commons Logging instance.
protected  java.lang.String name
          Name to insert
protected  javax.servlet.jsp.PageContext pageContext
          Trick to allows inner classes to access pageContext
protected  boolean processEndTag
          Does the end tag need to be processed.
protected  InsertTag.TagHandler tagHandler
          Finale handler of tag methods
 
Fields inherited from class org.apache.struts.taglib.tiles.DefinitionTagSupport
controllerName, controllerType, page, role
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id
 
Fields inherited from interface org.apache.struts.taglib.tiles.ComponentConstants
COMPONENT_CONTEXT, COMPONENT_SCOPE, EXCEPTION_KEY, LOCALE_KEY
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
InsertTag()
           
 
Method Summary
 InsertTag.TagHandler createTagHandler()
          Process tag attribute and create corresponding tag handler.
 int doEndTag()
          Process the end tag by including the template.
protected  void doInclude(java.lang.String page)
          Do an include of specified page using pageContext.include() This method is used internally to do all includes
 int doStartTag()
          Process the start tag by checking tag's attributes and creating appropriate handler.
 java.lang.String getBeanName()
          Get the property.
 java.lang.String getBeanProperty()
          Get the property.
 java.lang.String getBeanScope()
          Get the property.
private  Controller getController()
          Get instanciated Controller.
private  ComponentContext getCurrentContext()
          Get current component context.
 java.lang.String getDefinitionName()
          Get the property.
 boolean getFlush()
          Get the property.
 boolean getIgnore()
          Get the property.
 java.lang.String getName()
          Get the property.
 javax.servlet.jsp.PageContext getPageContext()
          Get the pageContext property
 InsertTag.TagHandler processAsDefinitionOrURL(java.lang.String name)
          Try to process name as a definition, or as an URL if not found.
 InsertTag.TagHandler processAttribute(java.lang.String name)
          Process tag attribute "attribute=".
protected  InsertTag.TagHandler processBean(java.lang.String beanName, java.lang.String beanProperty, java.lang.String beanScope)
          Process a bean.
protected  InsertTag.TagHandler processDefinition(ComponentDefinition definition)
          End of Process tag attribute "definition" Overload definition with tag attributes "template" and "role".
protected  InsertTag.TagHandler processDefinitionName(java.lang.String name)
          Process tag attribute "definition" First, search definition in the factory, then create handler from this definition.
 InsertTag.TagHandler processName(java.lang.String name)
          Process name.
 void processNestedTag(PutListTag nestedTag)
          Process nested ≶putList> tag.
 void processNestedTag(PutTag nestedTag)
          Process nested ≶put> tag.
 InsertTag.TagHandler processObjectValue(java.lang.Object value)
          Process an object retrieved as a bean or attribute.
 InsertTag.TagHandler processTypedAttribute(AttributeDefinition value)
          Process typed attribute according to its type.
 InsertTag.TagHandler processUrl(java.lang.String url)
          Process
 void putAttribute(PutListTag nestedTag)
          Method calls by nested ≶putList> tags.
 void putAttribute(java.lang.String name, java.lang.Object value)
          Add a body attribute.
 void release()
          Reset member values for reuse.
protected  void releaseInternal()
          Reset internal member values for reuse.
 void setAttribute(java.lang.String value)
          Set property
 void setBeanName(java.lang.String value)
          Set property.
 void setBeanProperty(java.lang.String value)
          Set property.
 void setBeanScope(java.lang.String value)
          Set property.
 void setComponent(java.lang.String name)
          Set property
 void setDefinition(java.lang.String name)
          Set property
 void setFlush(boolean flush)
          Set property
 void setFlush(java.lang.String flush)
          Set property Method added for compatibility with JSP1.1
 void setIgnore(boolean ignore)
          Set ignore attribute
 void setInstance(java.lang.String name)
          Deprecated. Use setDefinition() instead.
 void setName(java.lang.String value)
          Set property.
 void setPageContext(javax.servlet.jsp.PageContext pc)
          Set the current page context.
 
Methods inherited from class org.apache.struts.taglib.tiles.DefinitionTagSupport
getControllerName, getControllerType, getPage, getRole, getTemplate, setController, setControllerClass, setControllerName, setControllerType, setControllerUrl, setPage, setRole, setTemplate
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.IterationTag
 

Field Detail

log

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


flush

protected boolean flush
Flush attribute value


name

protected java.lang.String name
Name to insert


attribute

protected java.lang.String attribute
Name of attribute from which to read page name to include


beanName

protected java.lang.String beanName
Name of bean used as entity to include


beanProperty

protected java.lang.String beanProperty
Name of bean property, if any


beanScope

protected java.lang.String beanScope
Scope of bean, if any


isErrorIgnored

protected boolean isErrorIgnored
Are errors ignored. This is the property for attribute 'ignore'. Default value is false, which throw an exception. Only 'attribute not found' errors are ignored.


definitionName

protected java.lang.String definitionName
Name of component instance to include


processEndTag

protected boolean processEndTag
Does the end tag need to be processed. Default value is true. Boolean set in case of ignored errors.


cachedCurrentContext

protected ComponentContext cachedCurrentContext
Current component context


tagHandler

protected InsertTag.TagHandler tagHandler
Finale handler of tag methods


pageContext

protected javax.servlet.jsp.PageContext pageContext
Trick to allows inner classes to access pageContext

Constructor Detail

InsertTag

public InsertTag()
Method Detail

release

public void release()
Reset member values for reuse. This method calls super.release(), which invokes TagSupport.release(), which typically does nothing.

Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class DefinitionTagSupport

releaseInternal

protected void releaseInternal()
Reset internal member values for reuse.


setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pc)
Set the current page context. Called by the page implementation prior to doStartTag().

Needed to allow inner classes to access pageContext.

Specified by:
setPageContext in interface javax.servlet.jsp.tagext.Tag
Overrides:
setPageContext in class javax.servlet.jsp.tagext.TagSupport

getPageContext

public javax.servlet.jsp.PageContext getPageContext()
Get the pageContext property


setName

public void setName(java.lang.String value)
Set property.


getName

public java.lang.String getName()
Get the property.


setComponent

public void setComponent(java.lang.String name)
Set property


setInstance

public void setInstance(java.lang.String name)
Deprecated. Use setDefinition() instead.

Set property


setDefinition

public void setDefinition(java.lang.String name)
Set property


getDefinitionName

public java.lang.String getDefinitionName()
Get the property.


setAttribute

public void setAttribute(java.lang.String value)
Set property


setBeanName

public void setBeanName(java.lang.String value)
Set property.


getBeanName

public java.lang.String getBeanName()
Get the property.


setBeanProperty

public void setBeanProperty(java.lang.String value)
Set property.


getBeanProperty

public java.lang.String getBeanProperty()
Get the property.


setBeanScope

public void setBeanScope(java.lang.String value)
Set property.


getBeanScope

public java.lang.String getBeanScope()
Get the property.


setFlush

public void setFlush(boolean flush)
Set property


getFlush

public boolean getFlush()
Get the property.


setFlush

public void setFlush(java.lang.String flush)
Set property Method added for compatibility with JSP1.1


setIgnore

public void setIgnore(boolean ignore)
Set ignore attribute


getIgnore

public boolean getIgnore()
Get the property.


putAttribute

public void putAttribute(java.lang.String name,
                         java.lang.Object value)
Add a body attribute. Erase any attribute with same name previously set.


processNestedTag

public void processNestedTag(PutTag nestedTag)
                      throws javax.servlet.jsp.JspException
Process nested ≶put> tag. Method calls by nested ≶put> tags. Nested list is added to current list. If role is defined, it is checked immediately.

Specified by:
processNestedTag in interface PutTagParent
Parameters:
nestedTag - Nested to process.
javax.servlet.jsp.JspException

processNestedTag

public void processNestedTag(PutListTag nestedTag)
                      throws javax.servlet.jsp.JspException
Process nested ≶putList> tag. Method calls by nested ≶putList> tags. Nested list is added to sub-component attributes If role is defined, it is checked immediately.

Specified by:
processNestedTag in interface PutListTagParent
Parameters:
nestedTag - Nested PutTag defining the attribute.
javax.servlet.jsp.JspException

putAttribute

public void putAttribute(PutListTag nestedTag)
                  throws javax.servlet.jsp.JspException
Method calls by nested ≶putList> tags. A new list is added to current insert object.

javax.servlet.jsp.JspException

getCurrentContext

private ComponentContext getCurrentContext()
Get current component context.


getController

private Controller getController()
                          throws javax.servlet.jsp.JspException
Get instanciated Controller. Return controller denoted by controllerType, or null if controllerType is null.

Throws:
javax.servlet.jsp.JspException - If controller can't be created.

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Process the start tag by checking tag's attributes and creating appropriate handler. Possible handlers : Handlers also contain sub-component context.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.JspException

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Process the end tag by including the template. Simply call the handler doEndTag

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.JspException

createTagHandler

public InsertTag.TagHandler createTagHandler()
                                      throws javax.servlet.jsp.JspException
Process tag attribute and create corresponding tag handler.

javax.servlet.jsp.JspException

processObjectValue

public InsertTag.TagHandler processObjectValue(java.lang.Object value)
                                        throws javax.servlet.jsp.JspException
Process an object retrieved as a bean or attribute. Object can be a typed attribute, a String, or anything else. If typed attribute, use associated type. Otherwise, apply toString() on object, and use returned string as a name.

Throws:
javax.servlet.jsp.JspException - - Throws by underlying nested call to processDefinitionName()

processName

public InsertTag.TagHandler processName(java.lang.String name)
                                 throws javax.servlet.jsp.JspException
Process name. Search in following order :

Returns:
appropriate tag handler.
Throws:
javax.servlet.jsp.JspException - - Throws by underlying nested call to processDefinitionName()

processUrl

public InsertTag.TagHandler processUrl(java.lang.String url)
                                throws javax.servlet.jsp.JspException
Process

Throws:
javax.servlet.jsp.JspException - If failed to create controller

processDefinitionName

protected InsertTag.TagHandler processDefinitionName(java.lang.String name)
                                              throws javax.servlet.jsp.JspException
Process tag attribute "definition" First, search definition in the factory, then create handler from this definition.

Parameters:
name - Name of the definition.
Returns:
Appropriate TagHandler.
Throws:
JspException- - NoSuchDefinitionException No Definition found for name.
JspException- - FactoryNotFoundException Can't find Definitions factory.
JspException- - DefinedComponentFactoryException General error in factory.
javax.servlet.jsp.JspException - InstantiationException Can't create requested controller

processDefinition

protected InsertTag.TagHandler processDefinition(ComponentDefinition definition)
                                          throws javax.servlet.jsp.JspException
End of Process tag attribute "definition" Overload definition with tag attributes "template" and "role". Then, create appropriate tag handler.

Parameters:
definition - Definition to process.
Returns:
Appropriate TagHandler.
Throws:
javax.servlet.jsp.JspException - InstantiationException Can't create requested controller

processBean

protected InsertTag.TagHandler processBean(java.lang.String beanName,
                                           java.lang.String beanProperty,
                                           java.lang.String beanScope)
                                    throws javax.servlet.jsp.JspException
Process a bean. Get bean value, eventually using property and scope. Found value is process by processObjectValue().

Returns:
Appropriate TagHandler.
Throws:
javax.servlet.jsp.JspException - - NoSuchDefinitionException No value associated to bean.
javax.servlet.jsp.JspException - an error occur while reading bean, or no definition found.
javax.servlet.jsp.JspException - - Throws by underlying nested call to processDefinitionName()

processAttribute

public InsertTag.TagHandler processAttribute(java.lang.String name)
                                      throws javax.servlet.jsp.JspException
Process tag attribute "attribute=". Get value from component attribute. Found value is process by processObjectValue().

Parameters:
name - Name of the attribute.
Returns:
Appropriate TagHandler.
Throws:
javax.servlet.jsp.JspException - - NoSuchDefinitionException No Definition found for name.
javax.servlet.jsp.JspException - - Throws by underlying nested call to processDefinitionName()

processAsDefinitionOrURL

public InsertTag.TagHandler processAsDefinitionOrURL(java.lang.String name)
                                              throws javax.servlet.jsp.JspException
Try to process name as a definition, or as an URL if not found.

Parameters:
name - Name to process.
Returns:
appropriate TagHandler
Throws:
javax.servlet.jsp.JspException - InstantiationException Can't create requested controller

processTypedAttribute

public InsertTag.TagHandler processTypedAttribute(AttributeDefinition value)
                                           throws javax.servlet.jsp.JspException
Process typed attribute according to its type.

Parameters:
value - Typed attribute to process.
Returns:
appropriate TagHandler.
Throws:
javax.servlet.jsp.JspException - - Throws by underlying nested call to processDefinitionName()

doInclude

protected void doInclude(java.lang.String page)
                  throws javax.servlet.ServletException,
                         java.io.IOException
Do an include of specified page using pageContext.include() This method is used internally to do all includes

Parameters:
page - The page that will be included
Throws:
javax.servlet.ServletException - - Thrown by call to pageContext.include()
java.io.IOException - - Thrown by call to pageContext.include()


Copyright 2000-2002 - Cedric Dumoulin and Apache Software Foundation