Announcement Announcement Module
Collapse
No announcement yet.
<form:checkbox ...> stopping flow event signals Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <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
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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!

        Comment

        Working...
        X