Saves a dynamic value to a variable.
<dsp:tomapvar-spec
source-spec
recursive="{true|false}"/>
Attributes
var-spec
An EL variable or scripting variable that is defined with one of these attributes:
Attribute | Description |
---|---|
| Names an EL variable. When you use |
| Names a scripting variable that scriptlets and expressions can access at runtime. |
source-spec
Specifies the variable to RepositoryItem bean, Page parameter, or Static value, as follows:
bean="
property
-
spec
"
Specifies a RepositoryItem property value, where
property-spec
includes a Nucleus path, component name, and (optionally) property name. For example:bean="Student_01.name"
param="
param-name
"
Specifies a page parameter.
value="
static-value
"
Specifies a static value.
recursive
If set to true, all underlying Dynamic Beans are wrapped as Maps and can be accessed through the EL variable. This can help simplify code that accesses multi-dimensional data. For example, if the RepositoryItem Profile
has a property fundList
which is itself a RepositoryItem, you can provide direct access to the fundList
property as follows:
<dsp:tomap bean="atg/userprofiling/Profile" var="profile" recursive="true"/> I own these mutual funds: <c:out value="${profile.fundList}"/>
If desired, you can access the underlying Dynamic Bean rather than its Map wrapper through the DynamicBeanMap property _realObject
. Thus, given the previous example, you might access the Dynamic Bean fundList
as follows:
${profile.fundList._realObject}
Usage Notes
dsp:tomap
provides access to Dynamic Bean components, standard JavaBean components, page parameters, and values by other tags that use EL or scripting variables. When you pass a parameter, component, or other value to a dsp:tomap
tag, the object that is referenced by the EL or scripting variable treats the input as a Map. For example, when you pass in a component, the component appears as a Map in which the properties are keys and the property values are values.
You must use dsp:tomap
in order to access a repository item through an EL expression.
Example
<dsp:tomap var="currentProfile" bean="Profile" recursive="true"/>
Hello <c:out value="${currentProfile.firstName}"/>
Do you still live in <c:out value="${currentProfile.address.city}"/>
In this example, the Profile
component is saved to the Map specified by currentProfile
, so other tags can use EL to render this component. Because the recursive
attribute is set to true
, the same EL variable provides access to underlying components such as the Dynamic Bean address
and its properties.