Tuesday 21 October 2008

Set the property of an HTML element dynamically

Well, for some reason I wanted change the property assigned to a checkbox element in my jsp page dynamically from an object in an array from my formbean
Here is how I did it:
{logic:iterate id="myList" name="someForm" property="arSomeList"}
{bean:define id="theVariableINeed" name="myList" property="theValueInArray"} {/bean:define}
{% String property=""; %}

{html:checkbox property=" '{%="property+theVariableINeed"%}' value=""}
{/html:checkbox}



Wow, looks so easy now, thought I spent hours trying to work it out :(


Note: { = < it was causing errors on blogger :)

No comments: