I've started using struts 2.1.2 as I was having some issues after
enabling client side javascript validation on forms (some page requests
hang, and clicking back takes you to the page you're supposed to be on).

 

I decided to use client side validation to avoid the problems of
populating form elements after validation fails (I'm using the action
tag to populate select drop-downs which I can't get to work after
validation errors return the page to the form).

 

Since moving to struts 2.1.2, I can't get client side validation to work
properly (some rules are skipped, but are then validated if the form
submits), and it only triggers after clicking the submit button (rather
than from the onblur event as in 2.0.11.x).

 

So I decided to try the ajax validation (seen on this page):

 

http://struts.apache.org/2.1.2/docs/ajax-validation.html

 

I've nearly done it, but now when I press submit I just get a browser
download of the json error fields, like so:

 

---

/* { "fieldErrors": {"daoDto.name":["Name must be in the format:
[A-Za-z0-9-_]*"],"daoDto.settings":["You must enter a value for
Settings"]}} */

--- 

 

 

I've scoured over the tutorial for what I might have done wrong, and I'm
not too hot with javascript, so I'm left a little confused.

 

I notice the jsp in the tutorial has an <s:url id="url"
namespace="/validation"../> tag which doesn't get used. Is there
supposed to be a different action for the ajax request than for the form
submission? 

 

I've set a hidden field in the form to set
struts.enableJSONValidation=true. Where else would I put this? I take it
this is making the submit to the action return the plain text json
notation?

 

 

Any Ideas?
----------------------------------------------------------
This transmission is strictly confidential, possibly legally privileged, and 
intended solely for the 
addressee.  Any views or opinions expressed within it are those of the author 
and do not necessarily 
represent those of 192.com, i-CD Publishing (UK) Ltd or any of it's subsidiary 
companies.  If you 
are not the intended recipient then you must not disclose, copy or take any 
action in reliance of this 
transmission. If you have received this transmission in error, please notify 
the sender as soon as 
possible.  No employee or agent is authorised to conclude any binding agreement 
on behalf of 
i-CD Publishing (UK) Ltd with another party by email without express written 
confirmation by an 
authorised employee of the Company. http://www.192.com (Tel: 08000 192 192).  
i-CD Publishing (UK) Ltd 
is incorporated in England and Wales, company number 3148549, VAT No. GB 
673128728.

Reply via email to