Reputation: 485
I have shown the arraylist values on UI. Arraylist contain the pojo class "Preference" The Preference class has 3 String members PreferenceName,PreferenceType and PreferenceValue.
In jsp i iterated the arraylist and shown the PreferenceName , and it's value (shown using radiobutton) wheather it is true or false.
Now when user submit the form . I want arraylist containing the values.I am using Spring. I am getting the other values but is there any way to get the arraylist values. So what i need to do..?
<c:forEach items="${preferences.preferenceList}" var="preference">
<tr height="35px" bgcolor="#fafafa" bordercolor="#FFF">
<td width="50%"><c:out value="${preference.preferenceName}"/></td>
<td width="20%">
<c:if test="${preference.preferenceType=='boolean'}">
<c:if test="${preference.preferenceValue=='true'}">
<input type="radio" name="${preference.preferenceName}" value="true" checked="true">Yes
<input type="radio" name="${preference.preferenceName}" value="false" >No
</c:if>
<c:if test="${preference.preferenceValue=='false'}">
<input type="radio" name="${preference.preferenceName}" value="true" > Yes
<input type="radio" name="${preference.preferenceName}" value="false" checked="true" >No
</c:if>
</c:if>
</td>
</tr>
</c:forEach>
Upvotes: 0
Views: 293
Reputation: 2167
Try this:
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<c:forEach items="${preferences.preferenceList}" var="preference" varStatus="itemRow">
<c:set var="varPath" value="preferenceList[${itemRow.index}]"/>
<tr height="35px" bgcolor="#fafafa" bordercolor="#FFF">
<td width="50%">
<form:label path="${varPath}.preferenceName">${preference.preferenceName}</form:label>
</td>
<td width="20%">
<c:if test="${preference.preferenceType=='boolean'}">
<form:radiobutton path="${varPath}.preferenceValue" value="true">Yes</form:radiobutton>
<form:radiobutton path="${varPath}.preferenceValue" value="false">No</form:radiobutton>
</c:if>
</td>
</tr>
</c:forEach>
Upvotes: 1