I'm trying to get the ajax validations working in my Struts 2.1.8.1 application. I'm not using any of the built in struts ajax tags so that makes things slightly more complicated but I've been following the directions here: http://struts.apache.org/2.1.8/docs/ajax-validation.html
My problem is that the jsonValidationWorkflowStack is always returning an empty JSON object even if the console is reporting that the validations did in fact fail:
/* {} */
[3/15/10 12:02:42:218 CDT] 00000022 ChangeRequest E com.opensymphony.xwork2.util.logging.commons.CommonsLogger error Validation error for requestDTO.contractorSerialNumber:Serial Number is required!
[3/15/10 12:02:42:265 CDT] 00000022 ChangeRequest E com.opensymphony.xwork2.util.logging.commons.CommonsLogger error Validation error for requestDTO.contractorSerialNumber:Serial Number is required!
Here is the struts.xml action declaration:
<action name="updateSerialNumberAndPersonnelSystemCode" method="updateSerialNumberAndPersonnelSystemCode" class="changeRequestAction">
<interceptor-ref name="jsonValidationWorkflowStack"/>
<result>pages/serialNumberAndBluePages.jsp</result>
<result name="input">pages/serialNumberPopup.jsp</result>
</action>
Here is the javascript that makes the ajax request:
function submitValidatedAjaxRequest(ajaxUrl, formId, onCompleteCallBack) {
var erorsDomElement = formId + "Errors";
clearErrors(erorsDomElement);
var loadFunctionClosure = function (data) {
var form = dojo.byId(formId);
var errorsObject = StrutsUtils.getValidationErrors(data);
if(errorsObject.fieldErrors) {
displayErrors(errorsObject);
} else {
submitNonValidatedAjaxRequest(ajaxUrl, formId, onCompleteCallBack);
}
}
dojo.xhrGet( {
url: ajaxUrl,
form: dojo.byId(formId),
content: {'struts.validateOnly':'true',
'struts.enableJSONValidation':'true'},
load: loadFunctionClosure,
error: onAjaxError
} );
}
Everything seems to be as the howto described, but the json validator refuses to return the validation errors. Has anyone seen this before?