views:

30

answers:

1

Hi.

Is there a way to do the following thing in Struts / JSP?

<html:checkbox property="list.get(0).checked" />

Thank you in advance.

+2  A: 

If you want to access the 3rd element in a list in JSTL, the syntax is just like arrays:

<html:checkbox property="list[2].checked" />

Note that if you are new to JSTL/EL you'll have to add the appropriate jar to your classpath and reference the tag library.

lucas
Thank you. And if I want to create a checkbox that sets the 3rd element of a collection? I think your code example would get my the value of the element, wouldn't it?
Bernhard V
Ok, it worked. `<html:checkbox property="list[3].checked" />`
Bernhard V
Cool. I wasn't sure whatever was in your list had a checked property or not, so just left it out. I'll update my answer.
lucas