Export to GitHub

struts2-jquery - issue #740

Ajax validation messages display don't work.


Posted on Jan 4, 2012 by Happy Giraffe

(This is for feature requests and bugs in Struts2 jQuery Plugin - for getting help, please use the User Group. http://groups.google.com/group/struts2-jquery )

What steps will reproduce the problem? 1.I create form with Ajax-validation. <s:form id="formValidate" theme="xhtml" action="inputcheck" onsubmit="return false;">...... <sj:submit targets="main" button="true" buttonIcon="ui-icon-refresh" validate="true" validateFunction="customValidation" onBeforeTopics="removeErrors" onSuccessTopics="removeErrors" value="submit" indicator="indicator"></sj:submit> </s:form>

This submit button work fine, and struts2 validate request parameters correctly.

  1. struts2-json plugin returned this JSON response. { "fieldErrors": {"password":["\u30D1\u30B9\u30EF\u30FC\u30C9\u306F\u5FC5\u9808\u5165\u529B\u3067\u3059\u3002"],"mailAddress":["\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u306F\u5FC5\u9808\u5165\u529B\u3067\u3059\u3002"],"phone":["\u96FB\u8A71\u756A\u53F7\u306F\u5FC5\u9808\u5165\u529B\u3067\u3059\u3002"],"name":["\u540D\u524D\u306F\u5FC5\u9808\u5165\u529B\u3067\u3059"]}}

  2. Browser(Chrome16.0.912.63) received the JSON response correctly, but raise the script error in jquery.struts2-3.2.1.js line 206.

var errors = $.parseJSON(et.substring(2, et.length - 2));

unexpected token :

What is the expected output? What do you see instead?

I solved that problem changes that line.

var errors = $.parseJSON(et);

I changes this script and reload application , Ajax validation work fine.

Which struts2 version? Struts2.3.1 + JSON plugin2.3.1 + Convention plugin2.3.1

Which struts2-jquery plugin version? Version 3.2.0 and 3.2.1

Please provide any additional information below.

Comment #1

Posted on Jan 4, 2012 by Swift Lion

Since Version 2.3.1 Strust2 does return a valid JSON Result instead of a commended String result.

Comment #2

Posted on Jan 5, 2012 by Swift Lion

If you are using a custum function this Issue is fixed.

http://code.google.com/p/struts2-jquery/source/detail?r=1584

When using the Struts2 Validation Scripts for css_xhtml and xhtml theme, then you need to wait for the next version where this Struts2 Issue should be fixed.

https://issues.apache.org/jira/browse/WW-3736

Comment #3

Posted on Jan 5, 2012 by Happy Giraffe

thanks! I got it.

Comment #4

Posted on Mar 13, 2012 by Swift Lion

(No comment was entered for this change.)

Status: Fixed

Labels:
Type-Defect Priority-Medium Component-Plugin Milestone-3.3.0