-
1. Re: Handling Post requests to update node content
msulliva Jul 27, 2013 6:56 PM (in response to krisgumm)This should work, perhaps it's that <%currentNode.getPath();%> doesn't output anything in your form action (to output use <%= property %> without the semicolon instead of the scriptlet <% %> which just evaluates the contents instead of outputing), it seems CQ inserts a parent there in the action for some reason, in your case /content, so your form is posting to /content which isn't where your POST.jsp is located. The path you really probably want is to post directly to your component, which would look something like /content/Trainingsite/_jcr_content.html which would be output by <%= currentNode.getPath() %>.html, I used the ${currentNode.path} / ${currentPage.path} EL syntax in my example because I think it's cleaner looking and avoids the scriptlet confusion.
That said, why not just use the Sling Post Servlet [1] which will save the contents of the form and use the redirect option to avoid the standard Sling output (note the ./ prefix to the property names, this tells the post servlet to store that value at wherever your form action is posting to):
<%@include file="/libs/foundation/global.jsp"%>
<%@page session="false"%>
<h1>Hello ${properties.name}</h1>
<p>From: ${properties.address}</p>
<form action="${currentNode.path}.html" method="POST" enctype="multipart/form-data">
<input type="text" name="./name" value="${properties.name}" placeholder="Name" /><br />
<input type="text" name="./address" value="${properties.address}" placeholder="Address" /><br />
<input type="hidden" name=":redirect" value="${currentPage.path}.html" />
<input type="submit" id="submit" value="Submit" title="submit" />
</form>
[1] http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html#M anipulatingContent-TheSlingPostServlet%2528servlets.post%2529-%257B%257B%253Aredirect%257D %257Dhttp://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html

