1

I integrated HDIV and Spring MVC. Now I have a form on which there are three dropdown lists contract, taskorder and subtask. The select change of contract will update the content of taskorder dropdown list via ajax and then the select change of the task order will update the content of dropdown list subtask via ajax. The form looks like this:

 <c:url var="url" value="/admin/user/newstafftask" > 
 <c:param name="_MODIFY_HDIV_STATE_" value="${taskOrder.id}" />
</c:url>
<form:form action="${url}" commandName="newRequestStaffTasks">
    <form:hidden path="subId"  />
       <table >
            <tr>     
                <td> <label>Contract </label></td>
                <td>
                    <form:select path="newRequestStaffContract.id">
                      <option></option>
                      <form:options items="${contractList}" itemValue="id" itemLabel="contract.contractNbr" /> 
                    </form:select>
                </td>
        </tr>
        <tr>     
                <td> <label>Task Order </label></td>
                <td>
                    <form:select path="taskOrder.id">
                    </form:select>
                </td>
        </tr>
         <tr>     
                <td>  <label>SubTask Code </label></td>
                <td>
                    <form:select path="subtask.subTaskId">
                       <option></option>
                    </form:select>
                </td>
        </tr>
     </table>
</form:form>

When I tried to submit the form, I got the error message "INVALID_PARAMETER_NAME" about the taskOrder.id. I understand the problem is the values of two dropdown lists were updated on the client side.I tried _MODIFY_HDIV_STATE_, but it did not work with this case. So I am not sure how to deal with it now. Please help. Thanks.

Update 1

I already exclude the Ajax request from the HDIV validation. Below is the code snippet that update taskOrder list when the contract select change:

    $(".modal-body").on("change", "#newRequestStaffContract\\.id", function()  {
            getTaskOrderByContract($(this));
        });
        function getTaskOrderByContract(o) {
            contractId  = o.val();
            if (contractId)  {
                $.get("../../ajax/getTaskOrderByContract",  {
                    contractId : contractId
                }
                , function(data)  {
                    var options = '<option value=""></option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].id + '">' +data[i].taskNum+ '</option>';
                    }
                    $('#taskOrder\\.id').html(options);
                });
            };
        };  
Alex
  • 617
  • 2
  • 9
  • 21
  • Check this [example](https://github.com/hdiv/spring-mvc-showcase/blob/master/src/main/webapp/WEB-INF/views/partialform.jsp#L103) out. If you can, give us more information about how you generate the AJAX url. – Fernando Lozano Jun 26 '15 at 06:50
  • I did check the example. I already exclude the Ajax request from HDIV validation. So I have no problem about this piece. But the Ajax request will update the value of the dropdown list on the form newRequestStaffTasks . It causes the problem to submit form newRequestStaffTasks. Do I have to update the form action URL after I make an Ajax request here? – Alex Jun 26 '15 at 12:56
  • I've got a similar issue (or maybe the exact issue). One drop down when changed will cause another drop down to be updated with different values. Once this happens the auto-incremented "confidential" values never map back correctly to the true values. The only work around I've discovered is turning confidentiality off in the config. Would love to know the proper way to handle this. – tad604 Aug 07 '15 at 19:23
  • Can you post your hdiv config file ? – Derrick Nov 02 '18 at 10:54

0 Answers0