When registering a servlet for a new post action using the AEM Core Components, how does the form container know that the post will select this servlet? The code used below works...
@component(service = {Servlet.class}, property = {
ServletResolverConstants.SLING_SERVLET_METHODS + "=" + HttpConstants.METHOD_POST,
ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=" + "test/components/form/actions/customaction",
ServletResolverConstants.SLING_SERVLET_SELECTORS + "=" + "post"}, immediate = true)
public class CustomActionPostServlet extends SlingAllMethodsServlet {
It makes no sense, here you can see that I am trying to map the servlet to a SLING_SERVLET_RESOURCE_TYPES, but how does my custom action get called in this case?
does the AEM Core Components Forms container have some magic going on?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @ AEMWizard,
There is no magic in AEM Core Components Forms container implementation
This is how it works OOTB:
Examples of definition of OOTB actions can be found under:
In general proper way to use/extend OOTB Core Form is to create custom action, I have described how to do this under this topic:
Having above knowledge, lets try to answer your questions. In general it looks that your servlet is working, because your are not using OOTB one, and you have not extended Core Form in the way how it was designed. It seem that your servlet is executed directly instead of CoreFormHandlingServlet.
If you wanted to use custom servlet for from handling, then probably using Core Form was not the best choice. Because you are not using CoreFormHandlingServlet, to handle your form request you will not benefit from features Core Form provides, e.g. validation. The other drawback is a risk that other OOTB actions will not work correctly. Using a custom servlet is not a bad approach in general, but in that case it will be better to write custom form component as well. You do not need custom servlet to plugin custom action into Core Form.
Hi @ AEMWizard,
There is no magic in AEM Core Components Forms container implementation
This is how it works OOTB:
Examples of definition of OOTB actions can be found under:
In general proper way to use/extend OOTB Core Form is to create custom action, I have described how to do this under this topic:
Having above knowledge, lets try to answer your questions. In general it looks that your servlet is working, because your are not using OOTB one, and you have not extended Core Form in the way how it was designed. It seem that your servlet is executed directly instead of CoreFormHandlingServlet.
If you wanted to use custom servlet for from handling, then probably using Core Form was not the best choice. Because you are not using CoreFormHandlingServlet, to handle your form request you will not benefit from features Core Form provides, e.g. validation. The other drawback is a risk that other OOTB actions will not work correctly. Using a custom servlet is not a bad approach in general, but in that case it will be better to write custom form component as well. You do not need custom servlet to plugin custom action into Core Form.
Hi @lukasz-m,
1. What kind of validations are performed by CoreFormHandlingServlet?
2. Is there any way custom action invokes the CoreFormHandlingServlet and then it invokes the CustomServlet?
if yes, can you help me to with the detailed steps to achieve it?
Views
Likes
Replies