I have asked this question here:
java - AEM Form get all fields from custom submit - Stack Overflow
I need to write a custom form submit action.
So far I have a custom post.POST.jsp communicating with an OSGI service.
I have already followed this tutorial: Adobe Experience Manager Help | Creating a custom action for an Adobe Experience Manager Form compon...
Unfortunately this tutorial is a little basic.
I need to be able to read all field selections from a form without knowing in advance what the content authors might put there.
How can I achieve this?
Solved! Go to Solution.
Hi ciarans96415638
Depends on what your use cases are like - if it is one form that you have control of then you can restrict the fields that you add to the form inline with what your servlet can handle.
If you want to abide by a consistent structure - look to the "bound" data section of the xml, you can create an xsd or xdp schema to formalise your document structure and "bind" your fields on the form to prevent any expected field layouts creeping in.
I wrote an example of this the other day for another issue using an XSD. XDP might be better for your use case however if you later want to output to a PDF.
Create a new form and set the form model to use the following xml schema:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="user">
<xs:complexType>
<xs:sequence>
<xs:element name="userID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Associate it with a form:
Add a text field and bind it to the schema:
Then when you submit, you will see the field is now in the bound data section of the submitted XML.
This should give you more control.
Thanks,
Jim
Views
Replies
Total Likes
Hi ciarans96415638
Do you actually need a custom submit action? By default the POST to REST endpoint option will pass an XML representation of your form data with the request.
I have detailed the steps required to test this out here let me know if it helps.
Thanks,
James
Hi James R Green thanks for your reply.
I've rebuilt it in the way you suggested, working well and have an xml.
Is there a way to know what this xml will look like?
The form that is being submitted is multi step with a couple of different end points before they finally fill in contact information and hit submit. The xml I'm looking has my input fields but also other things that seem fragile.
For example there is a random <panel14942793831871494279383292/>
In my doPost method, can I get a list of all potential valid fields to then check if they have values and pull them out to save in a DB?
Views
Replies
Total Likes
Hi ciarans96415638
Depends on what your use cases are like - if it is one form that you have control of then you can restrict the fields that you add to the form inline with what your servlet can handle.
If you want to abide by a consistent structure - look to the "bound" data section of the xml, you can create an xsd or xdp schema to formalise your document structure and "bind" your fields on the form to prevent any expected field layouts creeping in.
I wrote an example of this the other day for another issue using an XSD. XDP might be better for your use case however if you later want to output to a PDF.
Create a new form and set the form model to use the following xml schema:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="user">
<xs:complexType>
<xs:sequence>
<xs:element name="userID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Associate it with a form:
Add a text field and bind it to the schema:
Then when you submit, you will see the field is now in the bound data section of the submitted XML.
This should give you more control.
Thanks,
Jim
Views
Replies
Total Likes