0

I have dragged the predefined Form component in my page.

enter image description here

I want to configure this form component i.e. by default it's points to itself, and data goes in BulkEditor. I want my data to be submitted to my own servlet. So how do I make the action="/MyServlet"

I also want to include my .js validation on this page, I tried using this link http://www.sfu.ca/itservices/cms/howto/advanced/style-a-page/customjavascript.html but I just don't have the option of adding .js in my page properties, why?

santiagozky
  • 2,519
  • 22
  • 31
Oliver
  • 6,152
  • 2
  • 42
  • 75

1 Answers1

2

CQ5 forms are submited into actions. In order to submit your form into a custom action you need to create an action resource type:

-Create a sling:Folder with a prop sling:resourceType= foundation/components/form/action

Then you create a script or servlet for that resourceType that respond to POST methods and the post selector. This can be a jsp post.Post.jsp or a serlvlet (method=POST, selectors=post, extension=html).

To create a custom validation, you create a clientvalidation.jsp file under that same resourceType.

After that, you can edit your form and select your action.

Adobe documentation about it is pretty straighforward

santiagozky
  • 2,519
  • 22
  • 31
  • I was able to post my data to SlingServlet using custom ActionType. Now I want to try another way, I want to Send data via AJax call to serlvet, the serlvet will return some result based to which I will redirect to a page. So where do I add this .js file .ie the file that contains the AJAX call !! and how do I use JQuery in CQ, like everyone, I would prefer Jquery.Ajax call as its easy $.ajax(); PLEASE NOTE I'M USING PREDEFINED FORM COMPONENT SO I CAN'T DO STUFF LIKE to add .js file right as I don't have source code of componenet(form template) – Oliver Mar 13 '14 at 05:35