0

I managed to integrate HDIV and Spring MVC. Now HDIV generated security URLs for the static links. But when I tries to submit a link with a parameter, I always get error message. I know the reason is when the URL of a form is generated, the parameter is not a part of the URL. But I cannot find a workaround. Please help. Thanks a lot.

The form part is like this:

<c:url var="url" value="/contract/report/report" />
<form:form action="${url}"  method="get">
    <table >
        <tr>
            <td><label>Name:</label></td>
            <td><select id="nameId" name="nameId">
                <c:forEach var="c" items="${Users}">
                    <option value='${c.id}'> ${c.name}</option>
                </c:forEach>
            </select> </td>
            <td><Button type="submit" >Submit</Button>  </td>
        </tr>
    </table>
</form:form>

Update:

I found the workaround is I have to rewrite the select options with spring options like this:

<form:select path="contractId">
 <c:forEach var="c" items="${Users}">
     <form:option value="${c.id}" label="${c.name}"></form:option>
 <c:forEach var="c" items="${Users}">
</form:select>

Thanks everyone.

Alex
  • 617
  • 2
  • 9
  • 21
  • For forms you don't need use `curl`. If configured properly there should be a hidden field with the HDIV state. Check your generated source. – seenukarthi Sep 22 '14 at 06:32

3 Answers3

1

If you want to add a parameter to the URL then this might work.

<c:url var="url" value="/contract/report/report"><c:param name="parameter" value="value" /></c:url>
superbAfterSemperPhi
  • 1,292
  • 1
  • 14
  • 27
  • It will not work because the value of the parameter(userId) is from a drop down list. – Alex Sep 19 '14 at 19:32
0

Don't use c:url for forms, you don't need it:

<form:form action="${pageContext.servletContext.contextPath}/contract/report/report" method="get">
     ...
</form:form>
gillarramendi
  • 271
  • 1
  • 8
  • There is no hidden HDIV state if I use this method. But I will get another issue.When I click the submit button, the page URL becomes : http://localhost:8080/myapp/contract/report/report?contractId=1. The new generated URL will be a security URL which HDIV wont recognize it without HDIV state. I get the error HDIV_PARAMETER_NOT_EXISTS now. – Alex Sep 22 '14 at 12:34
0

I found the workaround is I have to rewrite the select options with spring options like this:

<form:select path="contractId">
 <c:forEach var="c" items="${Users}">
     <form:option value="${c.id}" label="${c.name}"></form:option>
 <c:forEach var="c" items="${Users}">
</form:select>

Thanks everyone.

Alex
  • 617
  • 2
  • 9
  • 21