Expand my Community achievements bar.

SOLVED

Core Form Container - Post Form Data - Submit - Not working in AEM as a cloud

Avatar

Level 2

Hi Team,

 

     In AEM as a Cloud (ver 2022.9.8722.20220912T101352Z-220800), we are using the Core Form Container to build a Simple form which contains Form Text, Form Options and a Form Button. On clicking the Submit button, I am getting the below Forbidden error and from my custom log configuration, I could see that my servlet is not getting called and can't able to see any errors related to this in error.log file as well. Since, it is a OOTB core component, not sure on what we are missing here. Could you please help us on how to get these form data to our backend? Thanks.

 

Dialog:

Saran_K_2-1667097315459.png

 

Form: 

Saran_K_3-1667097463429.png

 

MyServlet:

@component(service = Servlet.class, property = { "sling.servlet.methods=" + HttpConstants.METHOD_POST,
"sling.servlet.paths=/bin/myproject/formpoc", "sling.servlet.selectors=formHandler",
"sling.servlet.extensions=html" })
public class GetFormDataPoc extends SlingAllMethodsServlet {

private static final Logger log = LoggerFactory.getLogger(GetFormDataPoc.class);

@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
log.debug("@@@ Inside doPost of GetFormDataPoc");
}
}

On Submit the form:

Saran_K_4-1667097716955.png

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

ok, the one I created was to store data in AEM

action="/content/usergenerated/<some-path>/cq-gen1655981669857/"
actionType="foundation/components/form/actions/store"

 

In you case you have to create the above Endpoint (servlet) and use relative path if it in AEM and register with sling resourcetype but not via path otherwise you may have issue when you deploy to cloud.



Arun Patidar

View solution in original post

8 Replies

Avatar

Community Advisor

Here are a few things you can do to troubleshoot the issue: 

  • Check the status of GetFormDataPoc Servlet in the OSGi console. Is it active? 
  • Use the Sling Servlet Resolver to test the servlet path - /bin/myproject/formpoc.formHandler.html with POST Method type.
  • To which path is the form container posting data when you click the submit button? Check this in the browser network tab. 

Avatar

Level 1

Hi @Lokesh_Vajrala,

 

Please find the responses inline,

  • Check the status of GetFormDataPoc Servlet in the OSGi console. Is it active?       Yes, the bundle is in Active state with this servlet in it.
  • Use the Sling Servlet Resolver to test the servlet path - /bin/myproject/formpoc.formHandler.html with POST Method type.       Saran2_0-1667196327189.png

     

  • To which path is the form container posting data when you click the submit button? Check this in the browser network tab.         In the network tab, i cant able to see any calls on submitting the button.Saran2_1-1667196455834.png

     

    Please let me know if any more information is required, Thanks.

Avatar

Community Advisor

Hi,

It seems user don't have write access at /content/usergenerated path, where data is going to be stored.



Arun Patidar

Avatar

Level 1

Hi @arunpatidar, But I am doing this in my author environment with admin user.

Avatar

Community Advisor

Hi,

With admin user, it should work.

Can you check your form container, if all the configurations are correct? 



Arun Patidar

Avatar

Level 1

Yes @arunpatidar. Below is the snippet of my Core Form Container configurations. But, on clicking the submit button, I am getting the above said error with no trace of logs in error log and in my custom log and also in browser network tab. My bundle is in active state with my GetFormDataPoc registered in it. Still not sure on what is going wrong here.

 

Saran2_0-1667206189848.png

 

Avatar

Correct answer by
Community Advisor

ok, the one I created was to store data in AEM

action="/content/usergenerated/<some-path>/cq-gen1655981669857/"
actionType="foundation/components/form/actions/store"

 

In you case you have to create the above Endpoint (servlet) and use relative path if it in AEM and register with sling resourcetype but not via path otherwise you may have issue when you deploy to cloud.



Arun Patidar

Avatar

Level 2

I have similar issue. I am using Post from Data, but it is not hitting my servlet. My servlet url is /bin/stewart/procurementServlet. Not sure what am I missing.