You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fea jabi <zy...@hotmail.com> on 2006/01/03 17:37:29 UTC
struts logic:iterate ---- c:forEach of JSTL
In struts config file I have it as
<form-bean name="Form1" type=".........DynaValidatorForm ">
.......................
<form-property name="Items" type="java.util.ArrayList"/>
<form-property name="selectedItems" type="java.lang.String[]"/>
</form-bean>
<action
path="/PrepareHrsAction"
type="PrepareHrsAction"
name="Form1"
scope="session"
validate="false"
input="/Hrs.jsp">
<forward name="success" path="/Hrs.jsp" redirect="false"/>
</action>
In prepare action have the below which creates this list
private ArrayList getItems(DynaValidatorForm form1) {
LabelValueBean lblValueBean1 = new LabelValueBean("Visa1", "V1");
LabelValueBean lblValueBean2 = new LabelValueBean("MasterCard1", "M1");
LabelValueBean lblValueBean3 = new LabelValueBean("American Exp", "AE1");
//Options
ArrayList itemsList = new ArrayList();
itemsList .add(lblValueBean1);
itemsList .add(lblValueBean2);
itemsList .add(lblValueBean3);
............................
..............................
String[] selectedList = {lblValueBean3.getValue(),
lblValueBean1.getValue()
};
form1.set("Items", itemsList);
form1.set("SelectedItems", selectedList);
return itemsList;
}
In jsp
<table>
<c:forEach var="item" items="${Form1.Items}">
<tr>
<td>
<html:multibox name="Form1" property="selectedItems">
<bean:write name="item" property="value"/>
</html:multibox>
<bean:write name="item" property="label"/>
</td>
</tr>
</c:forEach>
</table>
It works fine with the <logic:iterate> tag. Only when trying to use JSTL
<c:forEach> the jsp doesn't get displayed correctly.
Any idea why is that?
Thanks.
_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org