Friday, October 3, 2008

Use of jsp scriptlet to index jsp array variable in struts

For that first we have to declare the array variable in the java form bean with its getters and setters as given below.

int[]chkvalue=new int[20];

public int[] getChkvalue() {

return chkvalue;

}

public void setChkvalue(int[] chkvalue) {

this.chkvalue = chkvalue;

}

Now we can index the element using scriptlet as given below in the jsp page.

Note: Please careful about the quotes

<logic:present name="list">
<logic:iterate id="id" name="list" indexId="ctr">
<html:checkbox name="id" value="" property='<%="chkvalue["+ ctr+"]"%>'>
</html:checkbox>
</logic:iterate>
</logic:present>

No comments: