aspose file tools*
The moose likes Struts and the fly likes Struts 2.1 Ajax based input validation inside innerHTML problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2.1 Ajax based input validation inside innerHTML problem" Watch "Struts 2.1 Ajax based input validation inside innerHTML problem" New topic
Author

Struts 2.1 Ajax based input validation inside innerHTML problem

qm westview
Greenhorn

Joined: Feb 22, 2009
Posts: 1

Hi,

I run into a problem when trying to run Struts 2.1 Ajax based form input and validation code inside innerHTML

I managed to get the validation working on the server but the Json based Ajax return simply does not go into the form code inside innerHTML. The browser treat the Ajax return as having no relationship with the request issuer. Coding steps are listed below:

This is the original Struts 2.1 based form and input validation code (the client/server validation logic runs fine when not using innerHTML approach):

The same code turned into the following when coming from the server:


Plus separate javascript code



I simply merged the above code into multiple line of strings and assigned to a dedicated div’s innerHTML:



I found the http request sent to the server, after the form submit was hit, did not include struts.enableJSONValidation=true. So I inserted the following code into innerHTML:



Then the reply from the server became truly Json basd:



But the problem is that the browser, both Firefox and IE, does not insert the above reply into the form, but treat it as totally irrelevant to the Struts 2.1 code inside the innerHTML and prompt the viewer to save/open it.

It seems to me that when using this innerHTML approach, somehow the javascript connection between the Struts2.1 code inside innerHTML and outside the innerHTML are lost.

I was wondering if there is anyway this innerHTML approach for Strtus 2.1 Ajax based form input validation would work.

Qmwestview

(Thanks David for editing suggestion)


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please repost with your code in code tags and disable HTML; it's difficult to read it as-is.
 
 
subject: Struts 2.1 Ajax based input validation inside innerHTML problem