JavaBeans supports indexed property values—that is, properties that store an ordered set of values in an array. In order to retrieve and set indexed properties, a JavaBean implements accessor methods that take an additional integer index parameter, as follows:

Object getX(int index);
void setX(int index, Object value);

where X is the property name. You can get and set the values of indexed properties by referencing the indexed property with this syntax:

property-spec[array-index]

where array-index is one of the following:

array-index can also be expressed in EL, where the expression resolves to an integer value, JavaBean property or page parameter.

In all cases, the array index must resolve to an integer between 0 and the array size. This integer is passed as an index argument to the accessor method for that property, which gets or sets the specified property element.

For example, the JavaBean Student_01 might have a Hobbies property that manages a list of hobbies. The JavaBean defines the following accessor methods:

String getHobbies(int which);
void setHobbies(int which, String hobby);

Given these methods, you can use dsp:valueof to display a given hobby from this property:

<dsp:valueof bean="Student_01.hobbies[0]">no hobby</dsp:valueof>

 
loading table of contents...