Using Shared Variables in Adaptive Tags
The pt:logic.data, variable, and collection tags allow
you to store editable shared variables, which can be used in attribute
value replacement or with the pt:logic.value tag.
The
pt:logic.data tag stores a data
object (a name=value pair) as an editable shared variable using the
key passed in. The
pt:logic.variable tag stores
an editable shared variable using the key and value passed in. If
either tag is used inside the
pt:logic.collection tag, the variables are stored directly in the parent collection.
If the tag is used alone, the key attribute is required. The variable
is only stored after the tag is finished processing all its contents.
A collection can only contain a single type of variable, such as string
variables or data objects.
Note: If a variable or collection with
the same name already exists, it will be overwritten. If the preexisting
variable is not editable, the tag will fail. Variable names cannot
contain the reserved character '.'.
<pt:logic.variable pt:key="title" pt:value="Administrator"/>
<pt:logic.data pt:key="myurl" name="Home" url="http://www.oracle.com/technology/documentation/index.html"/>
<pt:logic.collection pt:key="testcollection">
<pt:logic.data url="http://www.myco.com" name="My company"/>
<pt:logic.data url="http://www.otherco.com" name="Other company"/>
</pt:logic.collection>
<pt:logic.collection pt:key="teststringcollection">
<pt:logic.variable pt:value="my string data"/>
<pt:logic.variable pt:value="my other string data"/>
</pt:logic.collection>
The
pt:logic.value tag displays the value of the variable referenced by the
pt:value attribute. Variables can be set using the
pt:logic.data or
pt:logic.variable tags
as explained in the previous section. This tag can be used to reference
localized strings in message files.
<pt:logic.value pt:value="$title"/>
<pt:logic.value pt:value="$myurl.Home"/>