AJAX validation does not work when xhtml forms contain hidden form fields
-------------------------------------------------------------------------

                 Key: WW-2659
                 URL: https://issues.apache.org/struts/browse/WW-2659
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - Dojo Tags
    Affects Versions: 2.1.2
         Environment: struts2-core-2.1.2 struts2-dojo-plugin-2.1.2.jar 
xwork-2.1.1 Firefox-2.0.0.14 Ubuntu-Gutsy
            Reporter: Owen Berry


Problem: validation errors returned from the server can not be inserted into 
the page content.

StrutsUtils.showValidationErrors in utils.js tries to detect the theme that is 
being used for the form by checking to see if the first child node of the form 
is a table node (line 53). If you have a hidden form field, the first child 
node is actually the hidden field, so the code thinks you are using the 
css_xhtml theme and fails to report validation errors within the page correctly 
- instead it pops up a Javascript alert indicating: "Could not validate: 
form_user_firstName".

JSP Code:
  <s:form method="post" namespace="/nodecorate" action="mysettings_update" 
theme="xhtml" id="form">
    <s:textfield key="user.firstName" />
    <s:textfield key="user.lastName" />
    <s:textfield key="user.emailAddress" />
    <s:hidden name="user.version" />
    <sx:submit validate="true" ajaxAfterValidation="true" targets="response" 
showLoadingText="false" />
  </s:form>

A workaround is to make the hidden field part of the table:
  <tr style="display:none"><td colspan="2"><s:hidden name="user.version" 
/></td></tr>

In addition to the above, it would also be good if addErrorCSS() in 
css_xhtml/validation.js could actually report the error if it cannot figure out 
the layout of the page. See line 83-45.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to