views:

397

answers:

1

I'm trying to use a jQuery dialog to submit a form via ajax to my struts2 action. On success, I'm redirecting to a different page. This is working great. The issue I'm having is handling non-success result types from my action. What I'd like to happen is for my action/field errors to somehow get populated into my dialog so that the user can make the necessary changes and resubmit the form. Any thoughts would be greatly appreciated.

A: 

You should return any errors fromthe action wrapped as a json or formatted HTML whch van then be displayed in the dialog.

JQuery supports error handler method for the Ajax calls make sure you set the http response code properly ans you should be able handle errors differently from success cases.

Vinodh Ramasubramanian
So if I want to return a json object of errors, would I not allow my action to have a non-success result type then? If that's the case, I suppose then that I would inspect the json object in the client and either write the errors to the dialog or redirect to another page if no errors exist. So in this case, my struts mapping file wouldn't have much in it, right? Does that sound right?
fmpdmb