Friday, May 8, 2015

How to submit a form using javascript in ATG

Today I spent lots of time to figure out how to submit a form in ATG platform. I tired many times and with the help of Google, I finally find the solution,

1. make sure to set type="hidden" to the input field of the formHandler  handleXXX method, like this:

<dsp:form id="myForm">
   ....
  .....
   <dsp:input type="hidden"  bean="MyFormHandler.handleMethod" value="" />

</dsp:form>


2. in  your javascript method, you just need to call:

$(#myForm).submit();


I found when I typed type="submit" for the input field, and  the handleXXX method is never called when the form is submitted through the javascript.

Resources:
1. https://community.oracle.com/thread/2471843
2. http://stackoverflow.com/questions/29300501/atg-formhandlerneed-to-set-some-values-before-calling-the-handle-method
3. http://www.mkthakral.com/j2ee/oracle-atg/atg-formhandler-ajax-call-using-jquery-json/

No comments:

Post a Comment