views:

739

answers:

1

Hi guys,

I'm currently developing with Struts 1 a web application. I've recently started to use AJAX technology and I'm stuck with something.

I call an action method (via AJAX) to validate my form but no values are changed in the form bean when it gets to the action method. I suppose this is because calling the action via AJAX doesn't submit the form to the action method. Am I right? I've tried to send form values as a JSON object, but I can't parse it in the action class because; as far as I know, I need an external library to do so and, unfortunately, company policies doesn't allow me to use external libraries. Is there any other way to send the form?

Thanks in advance, Carlos

A: 

Yes, you are correct. All that's happening with AJAX is a request is being sent to a particular URL, not a form submission.

The easiest way to deal with this is to add the fields you want validated as parameters in the URL then simply pull them off the HTTP request in the server (can't remember how easy that is with Struts).

Nick Holt
Aha, I see. I thought about that, but I wanted to avoid it because the form is quite big. I'll try it that way and see what happens.Thanks for your answer.
Carlos Pastor
I'm sure there's a way to get the parameters into the HTTP request (which is where they are with a form submit (I think)) and the effect will be the same server-side.
Nick Holt