org.apache.struts.taglib.tiles

Class InsertTag

public class InsertTag extends DefinitionTagSupport implements PutTagParent, ComponentConstants, PutListTagParent

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

Version: $Rev: 165160 $ $Date: 2005-04-28 17:29:58 +0100 (Thu, 28 Apr 2005) $

Nested Class Summary
protected classInsertTag.DirectStringHandler
Handle insert direct string.
protected classInsertTag.InsertHandler
Real handler, after attribute resolution.
protected interfaceInsertTag.TagHandler
Inner Interface.
Field Summary
protected Stringattribute
Name of attribute from which to read page name to include.
protected StringbeanName
Name of bean used as entity to include.
protected StringbeanProperty
Name of bean property, if any.
protected StringbeanScope
Scope of bean, if any.
protected ComponentContextcachedCurrentContext
Current component context.
protected StringdefinitionName
Name of component instance to include.
protected booleanflush
Flush attribute value.
protected booleanisErrorIgnored
Are errors ignored.
protected static Loglog
Commons Logging instance.
protected Stringname
Name to insert.
protected PageContextpageContext
Trick to allows inner classes to access pageContext.
protected booleanprocessEndTag
Does the end tag need to be processed.
static StringROLE_DELIMITER
The role delimiter.
protected InsertTag.TagHandlertagHandler
Final handler of tag methods.
Method Summary
InsertTag.TagHandlercreateTagHandler()
Process tag attribute and create corresponding tag handler.
intdoEndTag()
Process the end tag by including the template.
protected voiddoInclude(String page)
Do an include of specified page.
intdoStartTag()
Process the start tag by checking tag's attributes and creating appropriate handler.
StringgetBeanName()
Get bean name.
StringgetBeanProperty()
Get bean property.
StringgetBeanScope()
Get bean scope.
ControllergetController()
Get instantiated Controller.
ComponentContextgetCurrentContext()
Get current component context.
StringgetDefinitionName()
Get definition name.
booleangetFlush()
Get flush.
booleangetIgnore()
Get ignore.
StringgetName()
Get name.
PageContextgetPageContext()
Get the pageContext property.
InsertTag.TagHandlerprocessAsDefinitionOrURL(String name)
Try to process name as a definition, or as an URL if not found.
InsertTag.TagHandlerprocessAttribute(String name)
Process tag attribute "attribute".
protected InsertTag.TagHandlerprocessBean(String beanName, String beanProperty, String beanScope)
Process a bean.
protected InsertTag.TagHandlerprocessDefinition(ComponentDefinition definition)
End of Process tag attribute "definition".
protected InsertTag.TagHandlerprocessDefinitionName(String name)
Process tag attribute "definition".
InsertTag.TagHandlerprocessName(String name)
Process name.
voidprocessNestedTag(PutTag nestedTag)
Process nested ≶put> tag.
voidprocessNestedTag(PutListTag nestedTag)
Process nested ≶putList> tag.
InsertTag.TagHandlerprocessObjectValue(Object value)
Process an object retrieved as a bean or attribute.
InsertTag.TagHandlerprocessTypedAttribute(AttributeDefinition value)
Process typed attribute according to its type.
InsertTag.TagHandlerprocessUrl(String url)
Process the url.
voidputAttribute(String name, Object value)
Add a body attribute.
voidputAttribute(PutListTag nestedTag)
Method calls by nested ≶putList> tags.
voidrelease()
Reset member values for reuse.
protected voidreleaseInternal()
Reset internal member values for reuse.
voidsetAttribute(String value)
Set attribute.
voidsetBeanName(String value)
Set bean name.
voidsetBeanProperty(String value)
Set bean property.
voidsetBeanScope(String value)
Set bean scope.
voidsetComponent(String name)
Set component.
voidsetDefinition(String name)
Set definition.
voidsetFlush(boolean flush)
Set flush.
voidsetFlush(String flush)
Set flush.
voidsetIgnore(boolean ignore)
Set ignore.
voidsetName(String value)
Set name.
voidsetPageContext(PageContext pc)
Set the current page context.
static booleanuserHasRole(HttpServletRequest request, String role)
Parse the list of roles and return true or false based on whether the user has that role or not.

Field Detail

attribute

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

beanName

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

beanProperty

protected String beanProperty
Name of bean property, if any.

beanScope

protected String beanScope
Scope of bean, if any.

cachedCurrentContext

protected ComponentContext cachedCurrentContext
Current component context.

definitionName

protected String definitionName
Name of component instance to include.

flush

protected boolean flush
Flush attribute value.

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.

log

protected static Log log
Commons Logging instance.

name

protected String name
Name to insert.

pageContext

protected PageContext pageContext
Trick to allows inner classes to access pageContext.

processEndTag

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

ROLE_DELIMITER

public static final String ROLE_DELIMITER

Deprecated: This will be removed in a release after Struts 1.2.

The role delimiter.

tagHandler

protected InsertTag.TagHandler tagHandler
Final handler of tag methods.

Method Detail

createTagHandler

public InsertTag.TagHandler createTagHandler()
Process tag attribute and create corresponding tag handler.

doEndTag

public int doEndTag()
Process the end tag by including the template. Simply call the handler doEndTag

doInclude

protected void doInclude(String page)
Do an include of specified page. This method is used internally to do all includes from this class. It delegates the include call to the TilesUtil.doInclude().

Parameters: page The page that will be included

Throws: ServletException - Thrown by call to pageContext.include() IOException - Thrown by call to pageContext.include()

doStartTag

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

getBeanName

public String getBeanName()
Get bean name.

getBeanProperty

public String getBeanProperty()
Get bean property.

getBeanScope

public String getBeanScope()
Get bean scope.

getController

private Controller getController()
Get instantiated Controller. Return controller denoted by controllerType, or null if controllerType is null.

Throws: JspException If controller can't be created.

getCurrentContext

private ComponentContext getCurrentContext()
Get current component context.

getDefinitionName

public String getDefinitionName()
Get definition name.

getFlush

public boolean getFlush()
Get flush.

getIgnore

public boolean getIgnore()
Get ignore.

getName

public String getName()
Get name.

getPageContext

public PageContext getPageContext()
Get the pageContext property.

processAsDefinitionOrURL

public InsertTag.TagHandler processAsDefinitionOrURL(String name)
Try to process name as a definition, or as an URL if not found.

Parameters: name Name to process.

Returns: appropriate TagHandler

Throws: JspException InstantiationException Can't create requested controller

processAttribute

public InsertTag.TagHandler processAttribute(String name)
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: JspException - NoSuchDefinitionException No Definition found for name. JspException - Throws by underlying nested call to processDefinitionName()

processBean

protected InsertTag.TagHandler processBean(String beanName, String beanProperty, String beanScope)
Process a bean. Get bean value, eventually using property and scope. Found value is process by processObjectValue().

Parameters: beanName Name of the bean beanProperty Property in the bean, or null. beanScope bean scope, or null.

Returns: Appropriate TagHandler.

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

processDefinition

protected InsertTag.TagHandler processDefinition(ComponentDefinition definition)
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: JspException InstantiationException Can't create requested controller

processDefinitionName

protected InsertTag.TagHandler processDefinitionName(String name)
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. JspException InstantiationException Can't create requested controller

processName

public InsertTag.TagHandler processName(String name)
Process name. Search in following order :

Returns: appropriate tag handler.

Throws: JspException - Throws by underlying nested call to processDefinitionName()

processNestedTag

public void processNestedTag(PutTag nestedTag)
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.

processNestedTag

public void processNestedTag(PutListTag nestedTag)
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.

processObjectValue

public InsertTag.TagHandler processObjectValue(Object value)
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: JspException - Throws by underlying nested call to processDefinitionName()

processTypedAttribute

public InsertTag.TagHandler processTypedAttribute(AttributeDefinition value)
Process typed attribute according to its type.

Parameters: value Typed attribute to process.

Returns: appropriate TagHandler.

Throws: JspException - Throws by underlying nested call to processDefinitionName()

processUrl

public InsertTag.TagHandler processUrl(String url)
Process the url.

Throws: JspException If failed to create controller

putAttribute

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

putAttribute

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

release

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

releaseInternal

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

setAttribute

public void setAttribute(String value)
Set attribute.

setBeanName

public void setBeanName(String value)
Set bean name.

setBeanProperty

public void setBeanProperty(String value)
Set bean property.

setBeanScope

public void setBeanScope(String value)
Set bean scope.

setComponent

public void setComponent(String name)
Set component.

setDefinition

public void setDefinition(String name)
Set definition.

setFlush

public void setFlush(boolean flush)
Set flush.

setFlush

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

setIgnore

public void setIgnore(boolean ignore)
Set ignore.

setName

public void setName(String value)
Set name.

setPageContext

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

Needed to allow inner classes to access pageContext.

userHasRole

public static boolean userHasRole(HttpServletRequest request, String role)
Parse the list of roles and return true or false based on whether the user has that role or not.

Parameters: role Comma-delimited list of roles. request The request.

Copyright B) 2000-2009 - The Apache Software Foundation