Attributes for Struts tiles tags

This reference material describes the attributes for the Struts tiles tag library. By default, each element name has a tiles: prefix.

For more information about the Struts tags and tag attributes, refer to the Apache Struts specifications.

Each Struts tag has a number of attributes that you can set by using the Properties view of the tag. Use this table of attributes while working with the Properties view of the tag, to look up attributes for which you want additional detail. Some attributes have the same name but different usage in different elements. The attributes are listed in alphabetical order.

 

Add

Table 1. Add element properties
Attribute Description
beanName

Specifies the name of the bean whose value is to be used. The bean is retrieved from the specified context, if any. Otherwise, method pageContext.findAttribute is used. If you specify

beanProperty, the value is retrieved from the corresponding bean property.

beanProperty Specifies the name of a bean property whose value is to be retrieved. This attribute supports nested and indexed properties.
beanScope Specifies the scope in which the bean is searched for. By default, the method pageContext.findAttribute is used. The scope can be any JSP scope,

component, or

template. In the latter two cases, the bean is searched for in the tile context.

content Is a synonym for

value.

direct Specifies how content is handled:

true means that content is contained in the file;

false, the default, means that content is included from elsewhere. This is another way to specify content type. If you specify true, the content is interpreted as a string; otherwise, the content is interpreted as a page. This attribute exists for compatibility with the JSP template.

role Specifies a role that makes the element conditional. If the user is not in the specified role, the element is ignored, unless it is being used in a definition.
type Specifies one of the following content types:

definition

Specifies a definition that is defined in factory (XML file). The definition will be searched in the inserted tile, in an <insert attribute="attributeName"> tag, where attributeName is the name used for this tag.

page

Includes content from a specified URL. A synonym for this attribute is

template.

string

Provides content directly.
If you omit the

type attribute, the content is untyped unless it comes from a typed bean.

value Specifies the value of an element. The value can be a string or an object.

Return to the top of the page.

 

Definition

Table 2. Definition tag attributes
Attribute Description
extends Specifies the name of a parent definition that is used to initialize this new definition. The parent definition is searched in definitions factory.
id Specifies the name under which the newly created definition bean will be saved.
page Specifies URL of a tiles layout file (a type of JSP file) to insert.
role Specifies the role to check before inserting this definition. If role is not defined for current user, the definition is not inserted. Checking is done at insertion time, not during the definition process.
scope Specifies the variable scope into which the newly defined bean will be created. If you omit this attribute, the bean will be created in page scope.
template Is a synonym for

page.

Return to the top of the page.

 

Get

Table 3. Get element properties
Attribute Description
flush If

true, flushes the current page out stream before inserting a new page. The default is

false.

ignore Returns without writing anything if the value of this attribute is

true and the content specified by

name does not exist. The default value is

false, which causes a runtime exception to be thrown if the

name content does not exist.

name Specifies the name of the content to get from the tile scope.
role Causes the element to be ignored if the user is not in the specified role.

Return to the top of the page.

 

Get As String

Table 4. Get As String tag attributes
Attribute Description
ignore Returns without writing anything if the value of this attribute is

true and the attribute specified by

name does not exist. The default value is

false, which causes a runtime exception to be thrown if the attribute does not exist.

name Specifies an attribute name.
role Causes the element to be ignored if the user is not in the specified role.

Return to the top of the page.

 

Import Attribute

Table 5. Import Attribute tag attributes
Attribute Description
ignore

Returns without error if the value of this attribute is

true and the attribute specified by

name does not exist. The default value is

false, which causes a runtime exception to be thrown if the attribute does not exist.

name Specifies the name of the attribute to be imported. By default all attributes are imported.
scope Specifies the scope into which the attribute is imported. The default is

page.

Return to the top of the page.

 

Init Component Definitions

Table 6. Init Component Definitions element properties
Attribute Description
classname Specifies the class name of the factory to create and initialize.
file Specifies the name of the definition file.

Return to the top of the page.

 

Insert

Table 7. Insert tag attributes
Attribute Description
attribute Specifies the name of an attribute in the current tile context. The value of this attribute is passed to

name (see the description below).

beanName Inserts according to class type if the bean or property value found is an instance of one of Attribute class (Direct, Instance, and so forth). Otherwise, the toString method is called on the bean, and the returned

String class is used as name to insert (see

name below).

beanProperty Specifies the name of the bean property. This tag supports nested and indexed properties.
beanScope Specifies the scope of the bean search. If it is not specified, the method pageContext.findAttribute is used. Scope can be any JSP scope, component, or template. In the case of component and template, the bean is searched in the tile/component/template context.
component Specifies a string that represents the URI of a tile to insert.
controllerClass Specifies the Java™ class type of a controller called immediately before the page is inserted. The controller prepares data to be rendered by the inserted tile. The class must implement or extend one of the following classes:

  • org.apache.struts.tiles.Controller

  • org.apache.struts.tiles.ControllerSupport

  • org.apache.struts.action.Action (wrapper org.apache.struts.action.ActionController is used)
You cannot use

controllerClass with

controllerUrl.

controllerUrl Specifies the URL of a controller that is called immediately before the page is inserted. The URL usually denotes a Struts action. The controller (action) is used to prepare data to be rendered by the inserted tile. You cannot use

controllerUrl with

controllerClass.

definition Specifies the name of the definition to insert. Definitions are defined in a centralized file. This attribute can insert only definitions from a factory. To insert a definition defined with tag <tiles:definition>, use beanName="".
flush If set to

true, flushes the current page output stream before insertion.

ignore Returns without writing anything if the value of this attribute is

true and the attribute specified by

name does not exist. The default value is

false, which causes a runtime exception to be thrown if the attribute does not exist.

name Specifies the name of an entity to insert. The search for the entity is done in the following order : definition, attribute, tile.
page Is a synonym for

component.

role Causes the tag to be ignored if the user is not in the specified role.
template Is a synonym for

component.

Return to the top of the page.

 

Put

Table 8. Put element properties
Attribute Description
beanName

Specifies the name of the bean whose value is to be used. The bean is retrieved from the specified context, if any. Otherwise, method pageContext.findAttribute is used. If you specify

beanProperty, the value is retrieved from the corresponding bean property.

beanProperty Specifies the name of the bean property. This tag supports nested and indexed properties.
beanScope Specifies the scope of the bean search. If it is not specified, the method pageContext.findAttribute is used. Scope can be any JSP scope, component, or template. In the case of component and template, the bean is searched in the tile/component/template context.
content Is a synonym for

value.

direct Specifies how content is displayed.
name Specifies the name of the attribute that is being put.
role Causes the tag to be ignored if the user is not in the specified role.
type Specifies the content type:

string

Content is printed directly.

page, template

Content is included from a specified URL.

definition

The value denotes a definition defined in factory. The definition is searched in the inserted tile, in a <insert attribute="attributeName"> tag, where attributeName is the name used for this tag.
value Specifies an attribute value that is a string or an object. You must specify

value,

content, or

beanName.

Return to the top of the page.

 

Put List

Table 9. Put List tag attributes
Attribute Description
name Specifies the name of the list.

Return to the top of the page.

 

Use Attribute

Table 10. Use Attribute tag attributes
Attribute Description
classname Specifies the class of the declared variable.
id Specifies the declared attribute and variable name.
ignore

Returns without error if the value of this attribute is

true and the attribute specified by

name does not exist. The default value is

false, which causes a runtime exception to be thrown if the attribute does not exist.

name Specifies the attribute name of a tile.
scope Specifies the scope of the declared attribute. The default is

page.

Return to the top of the page.