Thursday, 19 September 2013

Spring post - multirow table

Spring post - multirow table

Hi im trying to recieve a table of inputs VIA POST method in my
controller, but i dont know why it returns me just the object alone or
null
Here is my implementation:
JSP:
<c:if test="${not empty configs}">
<form:form method="POST" id="propertiesForm" action="/configuracion"
modelAttribute="configs">
<table class="tablaListado" cellspacing="0">
<c:forEach var="o" items="${configs}" varStatus="status">
<tr class="renglonListado">
<td style="visibility: hidden;"
align="center">${status.count}</td>
<td class="colListado">${o.key}</td>
<td class="colListado">
<input type="text" class="valor"
name="configs[${status.index}].value" value="${o.value}"
onchange="marcarCambio(this.parentNode.parentNode);"/>
</td>
<td class="colListado"></td>
</tr>
</c:forEach>
</table>
</form:form>
</c:if>
CTRL:
@RequestMapping(value = "/configuracion", method= RequestMethod.POST)
public String login(HttpServletRequest request,
@ModelAttribute("configs") Object lista, ModelMap map) {
@SuppressWarnings("unchecked")
List<SystemConfiguration> list = (List<SystemConfiguration>) lista;
list.size();
return "configuracion";
}
Notice SystemConfiguration is my DTO class and im rendering a list ot
SystemConfiguration in my view passing it to the model in my GET method by
doing: model.addAttribute("configs", lista);
Where lista is: List lista = getConfigurations();

No comments:

Post a Comment