Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDIV and Spring: nesting <spring:url> tag in Spring's form tag breaks #4

Closed
sandermak opened this issue Aug 20, 2012 · 8 comments
Closed

Comments

@sandermak
Copy link

When creating a form like this:

<form:form method="POST" modelAttribute="bulkSelection">
<input type="submit" name="test" value="testbutton"/>
                    <form:checkbox path="pathvalue" value="${backingObject.path}"/> 
</form:form>

everything works as expected, and a hidden field is appended to the form containing the CSRF token. However, when I use a <spring:url> tag inside the form, the hidden CSRF token is suddenly not appended to the form anymore:

<form:form method="POST" modelAttribute="bulkSelection">
<input type="submit" name="test" value="testbutton"/>
        <form:checkbox path="pathvalue" value="${backingObject.path}"/> 
        <a href="<spring:url value ='/some/link' />">
                <img src="${pageContext.request.contextPath}/pic.png"/>
        </a>
</form:form>

It seems that something is going wrong in the DataComposerMemory class. Because in the first situation, in the getExtraHiddenFields method (see https://github.com/hdiv/hdiv/blob/master/hdiv-spring-mvc/src/main/java/org/hdiv/web/servlet/support/HdivRequestDataValueProcessor.java#L150) sees true when it calls DataComposer.isRequestStarted(), but in the second situation with the nested <spring:url> tag, it returns false!

When the <spring:url> tag is moved outside of the form, everything works correctly again:

  • the form gets its hidden CSRF token
  • the link gets the HDIV state parameter appended

Therefore the nesting causes the issue it seems.

@gillarramendi
Copy link
Member

Yes, there was a problem with nested tags and the system to manage nested states.
DataComposer.isRequestStarted was not correctly updated, so i have changed it:

b1d9823

This resolves the problem in my tests.

Thank you for your interest in HDIV

@sandermak
Copy link
Author

Wow, that was fast! Excellent work, it fixes our problem. When do you expect a version with this fix to be released to Maven Central?

@gillarramendi
Copy link
Member

We plan to release it in a few days

@gillarramendi
Copy link
Member

New version 2.1.2 is in Maven Central:
http://central.maven.org/maven2/org/hdiv/hdiv/2.1.2/

Regards

@yvnarasimharao
Copy link

hai, I am using Spring3.1 MVC with HDIV2.1.2. I go the same problem....

The log in the console is...........

INFO : org.hdiv.logs.Logger - HDIV_PARAMETER_NOT_EXISTS;
/mobee/mainMenu;1422131904;null;0:0:0:0:0:0:0:1;0:0:0:0:0:0:0:1;user
ERROR: org.hdiv.filter.ValidatorHelperRequest - Page with id [15] not found in session.
INFO : org.hdiv.logs.Logger - validation error: error, page (15) not found in session;
/mobee/mainMenu;1422131904;15-1-0AE5540ED32788A4E197BEB8C58D8617;0:0:0:0:0:0:0:1;0:0:0:0:0:0:0:1;user

.................please help me.

@gillarramendi
Copy link
Member

Hi,
can you attach the problematic JSP code, please?

Regards

@yvnarasimharao
Copy link

Hi,

Thanks for ur reply, please find the attachments
and I have the following exception for every request....

org.apache.jasper.JasperException: javax.servlet.ServletException:
javax.servlet.jsp.JspException: org.hdiv.exception.HDIVException:
IDataComposer has not been initialized in request

Please give the solution.....................

On Mon, Sep 17, 2012 at 5:30 PM, Gotzon Illarramendi <
notifications@github.com> wrote:

Hi,
can you attach the problematic JSP code, please?

Regards


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-8611918.

Thanks & Regards,
Y.V. Narasimha Rao.

@gillarramendi
Copy link
Member

Hi,
The error does not appear to be related to the issue. Please, submit an email to support@hdiv.org or ask a question on http://stackoverflow.com

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants