Results 1 to 4 of 4

Thread: <form:checkbox ...> stopping flow event signals

  1. #1
    Join Date
    Jan 2008
    Posts
    23

    Default <form:checkbox ...> stopping flow event signals

    Hi folks,

    Using SWF 1.0.5, and Spring 2.5, I've got a form with checkboxes, which whenever any of the checkboxes are checked, the trigger for the flow transition (selection) doesn't get sent, and so the view remains on the form page. However, if all the checkboxes are unchecked, then the selection transition trigger works fine.
    Here's some of the flow-xml:
    Code:
        <action-state id="CHOOSE">
            <bean-action bean="worker" method="updateList">
                <method-arguments>
                    <argument expression="flowScope.sess"/>
                </method-arguments>
            </bean-action>
            <bean-action bean="worker" method="testMethod">
                <method-arguments>
                    <argument expression="flowScope.sess"/>
                </method-arguments>
            </bean-action>
            <transition on="success" to="CHOOSE2"/>
        </action-state>
    
        <view-state id="CHOOSE2" view="choose">
            <render-actions>
                <action bean="formAction" method="setupForm"/>
            </render-actions>
            <transition on="selection" to="HANDLING">
                <action bean="formAction" method="bind"/>
            </transition>
            <transition on="none" to="CANCEL"/>
       </view-state>
    My jsp looks like this
    Code:
    <form:form commandName="sess" method="post">
        <c:forEach items="${sess.Options}" var="sessT">
            <%= rowCounter % 2 == 0 ? "<tr class=\"odd\">" : "<tr class=\"even\">" %>
            <% rowCounter++; %>
            <td>
               <form:checkbox path="userSelection" value="<c:out value='${sessT.id}'/>"/>
            </td>
            <td>
                <c:out value='${sessT.id}'/>
            </td>
    
            <td>
                <c:out value="${sessT.name}"/>
            </td>
    
            <td>
              <c:out value="${sessT.description}"/>
            </td>
    
            </tr>
        </c:forEach>
    
        </table>
    
        <br>
        <br>
    	<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}"/>
    	<input type="submit" class="button" name="_eventId_selection" value="Choose these ones"/>
    </form:form>
    <form type="post">
    	<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}"/>
    	<input type="submit" class="button" name="_eventId_none" value="Cancel and return"/>
    </form>
    userSelection is a java.util.list in the form backing class. The 'Choose these ones' button does nothing unless no checkboxes are selected. How can I make it work?

    Another (baffling) problem, is that at the previous action-state, only the first action: updateList is called, the testMethod isn't being called at all!?!

    Many thanks for any solutions.

  2. #2
    Join Date
    Jan 2008
    Posts
    23

    Default

    I've figured out the answer to my second question (the first action was returning success, so the transition occoured straight away). However I'm still thoroughly stuck on my main q regarding checkboxes, if anyone has any ideas.

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Put a form:errors some where in your form and you will probably notice that you have bind errors. I would guess a ClassCastException to java.util.List.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4
    Join Date
    Jan 2008
    Posts
    23

    Default

    Thanks!

    The problem seems to be fixed by changing
    Code:
    <form:checkbox path="userSelection" value="<c:out value='${sessT.id}'/>"/>
    to
    Code:
    <form:checkbox path="userSelection" value=${sessT.id}"/>
    I don't fully understand why, but I'm pleased to have it working!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •