In my jsp pages i just put a select without spring.
It works fine for me this is the old methode simple request parameters, convert in the bind methode to object,
Try it and tell me if it works ;-)
Fabien
In my jsp pages i just put a select without spring.
It works fine for me this is the old methode simple request parameters, convert in the bind methode to object,
Try it and tell me if it works ;-)
Fabien
This works, but I prefer to keep the <spring:bind> so I preceded the <input> names with a "_" so Spring does not see them while binding. This is not really elegant, but it works.
I think the Spring Team should modify the bind method to pass a string array to a custom editor when multiple form parameters with the same name are posted. Now we could do our stuff in regular propertyEditors.
Uze
Agree !
I like to make a customeditor in order to avoid a string[] to objects and objects to string[] conversion (or encapsulate this conversion) ?
Do u kown a sample ?
I going to sleep now it's late... see u soon,
Fabien
Hi,
Always no way for this ?
Thanks,
Fabien.
Check out this JIRA issue:Originally Posted by uze
http://opensource.atlassian.com/proj...browse/SPR-552
Here is a nice way to do that, all with pure spring tags :
you need a property checked (Boolean) in your driver object.
That will bind directly to your list, the checkbox. [/code]Code:<c:forEach items="${myDataModel.drivers}" var="driver" varStatus="loopStatus"> <spring:bind path="myDataModel.drivers[${loopStatus.index}].checked"> <input class="checkbox" type="checkbox" name ="<c:out values = "_${status.expression}"/>" value = "true" <c:if test="${status.value}">CHECKED</c:if> > </spring:bind> </c:forEach>
Thats for multiple checkboxes. Here's what I did to bind to the muliple select element.
Regards,Code:<spring:bind path="equipmentGroupForm.selectedEquipmentGroups"> <select name="<c:out value="${status.expression}"/>" multiple> <c:forEach var="equipmentGroup" items="${equipmentGroups}"> <c:out value="${status.value}" /> <% String equipmentGroup = ((EquipmentGroup)pageContext.getAttribute("equipmentGroup")).getName(); EquipmentGroupForm form = (EquipmentGroupForm)request.getAttribute("equipmentGroupForm"); Boolean eg_selected =Boolean.valueOf(form.isEquipmentGroupSelected(equipmentGroup)); pageContext.setAttribute("eg_selected", eg_selected); %> <option <c:if test="${eg_selected}">selected</c:if> value="<c:out value="${equipmentGroup.name}"/>"> <c:out value="${equipmentGroup.name}"/> </option> </c:forEach> </select> </spring:bind>
Sanjiv
Hello,
I am having an issue binding 'format' elements in beneath code.
I have a double loop:
The first loop binds the attribute 'docbase_name' in the 'repository' loop:
docshifterReceiverConfig.configuration.repositorie s.repository[${loopStatusRepo.index}].docbase_name
Works fine.
The second nested loop:
docshifterReceiverConfig.configuration.repositorie s.repository[${loopStatusRepo.index}].dctm_formats.format[${loopStatusFormats.index}] ,
wants to bind 'format[${loopStatusFormats.index}]' elements, but this does not happen, although the parent object 'Dctm_formats' has a setter method:
public void setFormat(
final int index,
final java.lang.String vFormat) {
this._formatList.set(index, vFormat);
}
and ${status.value} displays the correct value on my jsp page, but when changing this value and submitting the jsp, I do not get the new value in 'docshifterReceiverConfig' object.
complete code:
<c:forEach items="${docshifterReceiverConfig.configuration.re positories.repository}" var="repos" varStatus="loopStatusRepo">
<spring:bind path="docshifterReceiverConfig.configuration.repos itories.repository[${loopStatusRepo.index}].docbase_name">
<td width="40%">
<input name="<c:out value="${status.expression}"/>" value="<c:out value="${status.value}"/>">
</td>
</spring:bind>
<c:forEach items="${docshifterReceiverConfig.configuration.re positories.repository[loopStatusRepo.index].dctm_formats.format}" var="formats" varStatus="loopStatusFormats">
<spring:bind path="docshifterReceiverConfig.configuration.repos itories.repository[${loopStatusRepo.index}].dctm_formats.format[${loopStatusFormats.index}]">
<tr>
<td width="40%">
<input type="text" name="<c:out value="${status.expression}"/>" value="<c:out value="${status.value}"/>">
</td>
</tr>
</spring:bind>
</c:forEach>
</c:forEach>
could anyone help me out on this issue, many thx
I have the same situation. I want to know, How you collect those selected objects by checked check boxes into controller?
Last edited by beginner; Jun 9th, 2008 at 11:51 PM.