Announcement Announcement Module
Collapse
No announcement yet.
Multiple select value and spring:bind Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Here is a nice way to do that, all with pure spring tags :



    you need a property checked (Boolean) in your driver object.

    Code:
    <c&#58;forEach items="$&#123;myDataModel.drivers&#125;" var="driver" varStatus="loopStatus"> 
    
    <spring&#58;bind path="myDataModel.drivers&#91;$&#123;loopStatus.index&#125;&#93;.checked"> 
    	<input class="checkbox" type="checkbox"
                name ="<c&#58;out values = "_$&#123;status.expression&#125;"/>"
                value = "true" <c&#58;if test="$&#123;status.value&#125;">CHECKED</c&#58;if> >
    </spring&#58;bind>
    
    </c&#58;forEach>
    That will bind directly to your list, the checkbox. [/code]

    Comment


    • #17
      Thats for multiple checkboxes. Here's what I did to bind to the muliple select element.

      Code:
      <spring&#58;bind path="equipmentGroupForm.selectedEquipmentGroups">
         <select name="<c&#58;out value="$&#123;status.expression&#125;"/>"  multiple>
         <c&#58;forEach var="equipmentGroup" items="$&#123;equipmentGroups&#125;">  
         <c&#58;out value="$&#123;status.value&#125;" />
      <%
          String equipmentGroup = &#40;&#40;EquipmentGroup&#41;pageContext.getAttribute&#40;"equipmentGroup"&#41;&#41;.getName&#40;&#41;;
          EquipmentGroupForm form = &#40;EquipmentGroupForm&#41;request.getAttribute&#40;"equipmentGroupForm"&#41;;
          Boolean eg_selected =Boolean.valueOf&#40;form.isEquipmentGroupSelected&#40;equipmentGroup&#41;&#41;;
          pageContext.setAttribute&#40;"eg_selected", eg_selected&#41;;
      %>
      
          <option <c&#58;if test="$&#123;eg_selected&#125;">selected</c&#58;if> value="<c&#58;out value="$&#123;equipmentGroup.name&#125;"/>">
          <c&#58;out value="$&#123;equipmentGroup.name&#125;"/>
      </option>
      </c&#58;forEach>
      </select>
      </spring&#58;bind>
      Regards,
      Sanjiv

      Comment


      • #18
        Originally posted by olivier View Post
        Here is a nice way to do that, all with pure spring tags :



        you need a property checked (Boolean) in your driver object.

        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>
        That will bind directly to your list, the checkbox.

        May i know how u collect back those "checked" check boxes into controller and submit to JDBC?

        Comment


        • #19
          spring binding issue: binding the indexed element (format[${loopStatusF does not work

          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

          Comment


          • #20
            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, 11:51 PM.

            Comment


            • #21
              I have the same situation. If you've got the solution, please share....

              Comment

              Working...
              X