Expand my Community achievements bar.

SOLVED

On form submission getting the following error: javax.jcr.nodetype.ConstraintViolationException: No matching property definition: txn_type = PP

Avatar

Level 3

Hi,

I've my form as something like this:

t1.jsp:

<%@include file="/libs/foundation/global.jsp"%>
<%@page session="false" %>
<%@ page language="java" %>

<form name="frm" method="POST" id="frm" action="<%=resource.getPath()%>.html">
    <div>Enter your name<input type="text" name="nameX"/></div>
<input type="submit" name="submit" value="test"/>
</form>

 

POST.jsp:

<%@include file="/libs/foundation/global.jsp"%>
<%@ page session="false"%>
<%
String transaction_type = request.getParameter("namex");
log.info("teststttttt"+transaction_type);
%>

 

 

 

I'm getting error:

*ERROR* [127.0.0.1 [1437981615101] POST /content/abc/en/t1.html HTTP/1.1] org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception during response processing.
javax.jcr.nodetype.ConstraintViolationException: No matching property definition: nameX = kjkjkjkj

1 Accepted Solution

Avatar

Correct answer by
Level 10

When posting data from an HTML form to AEM - post the data to  a Sling Servlet using AJAX. See this community article:

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

You have much better control over how to process data by writing app logic in the Slign Servlet. IN this example - the posted data is encoded to JSON using the Simple JSON API. 

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

When posting data from an HTML form to AEM - post the data to  a Sling Servlet using AJAX. See this community article:

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

You have much better control over how to process data by writing app logic in the Slign Servlet. IN this example - the posted data is encoded to JSON using the Simple JSON API. 

Avatar

Level 3

Thanks Scott,

I have already did that and it worked very smoothly that way, but don't we have any simpler way to submit forms to a jsp file in CQ?

E.g. Suppose if my form is like <form action="submit_form.jsp" method="post">

then this won't work in case of adobe CQ, I just want to post all data of my form to second page and if I use servlets, then it would be bit lengthier to get the data first and then arrange it in proper format and send back to second page.

Avatar

Level 2

I am facing a similar issue when I am trying to submit my AMP(Accelerated Mobile Page) form.Please find the following link of the raised issue below and provide a solution if anyone has worked with AMP forms in AEM.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-platform/amp-accelerated-mobile-pa...