# <netui-template:setAttribute> Tag

The <netui-template:setAttribute> tag sets the value for a placeholder in a template page.

## Syntax

<netui-template:setAttribute
name="string_name"
value="string_or_expression_value" />

## Description

The <netui-template:setAttribute> tag sets the value for a placeholder in a template page.

The <netui-template:setAttribute> tag must have a parent <netui-template:template> tag.

The target placeholder is defined by a <netui-template:attribute> tag. For a value to be set in the placeholder, the <netui-template:attribute> and <netui-template:setAttribute> tags must have matching `name` attributes.

For example, a placeholder may be defined in the template.

In the template JSP page...

        <head>
            <title>
                <netui-template:attribute name="title"/>
            </title>
        </head>

Then content pages may set the value of this placeholder using the <netui-template:setAttribute> tag.

In a content JSP page...

        <netui-template:setAttribute name="title" value="myContentPage1.jsp"/>

The HTML rendered in the browser appears as follows.

Rendered HTML in the browser...

        <head>
            <title>
                myContentPage1.jsp
            </title>
        </head>

If the <netui-template:setAttribute> tag specifies no value to be set in the placeholder, then the <netui-template:attribute> tag's `defaultValue` will be used.

        <netui-template:attribute name="title" defaultValue="My Page"/>

The <netui-template:attribute> tag may also be used to define placeholders within JSP and HTML tags.

In the template JSP page...

        <td colspan="3" bgcolor="<netui-template:attribute name="headerColor" defaultValue="#ffffff"/>">

## Attributes

name | The name of the attribute to set.
Required | Supports runtime expression evaluation | Data bindable
Yes | No | No
value | Sets the value of the attribute.
Required | Supports runtime expression evaluation | Data bindable
Yes | No | Read Only

## Sample

Assume a <netui-template:attribute> tag defines a value placeholder within a <td> tag

        <td colspan="3" bgcolor="<netui-template:attribute name="headerColor" defaultValue="#ffffff"/>">

Now a content JSP page can control the background color of the <td>.

        <netui-template:setAttribute name="headerColor" value="lightgreen"/>

The HTML rendered in the browser will appear as follows.

        <td colspan="3" bgcolor="lightgreen">

## Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui_template/template/template.jsp

## Related Topics

<netui-template:...> Tags Sample

<netui-template:attribute> Tag

<netui-template:includeSection> Tag

<netui-template:section> Tag

<netui-template:template> Tag

<netui-template:visible> Tag