The value of the array index can be set from the value of another property. For example, if the Student_01 object also has a favoriteHobby property that stores an integer value, it can be used to specify which hobby to display:

<dsp:getvalueof bean="/samples/Student_01" var="student"/>

<dsp:valueof value="${student.hobbies[student.favoriteHobby]}">
I have no favorite hobby.
</dsp:valueof>

When the page is rendered, it uses the array index specified by favoriteHobby and returns the property element’s current value. All subsequent changes made to the array index property after the page is rendered to the browser have no effect on form submission.

Note: You can use array notation in some cases for a property that does not have the indexed setX and getX—for example, a property whose value is an array or a vector. However, if an ATG Servlet Bean needs to change the value of an element of your property because you referenced this property in a setvalue tag, it must have an indexed setX method.

 
loading table of contents...