Hi Darrel,
Darrell Pittman schrieb:
> I am not sure if this is the place to post how-to questions but here goes:
> Can someone tell me if it is possible to validate posted data (without
> relying on NodeTypes) and re-render the edit/add form with the posted data
> (and validation errors) upon validation failure.
Considering you are using Sling and SlingPostServlet to update data, you
are certainly at the right place ;-)
Currently, the SlingPostServlet just updates the repository with your
posted data without any validation.
But you have a series of options to cope with this.
You can have your specialized servlet checking the data and redirecting
to the form again in case of validation faliure. In case of validation
success you forward the request to the SlingPostServlet by overwriting
the resource type and optionally use a different resource path to apply
the data to, for example:
if (validate(request)) {
String actualResourcePath = ....;
RequestDispatcher rd = request.getRequestDispatcher(
actualResourcePath, "sling/servlet/default");
rd.forward(request, response);
} else {
// draw the form with messages
}
Alternatively you may install a request-level Filter which (on POST)
checks the input and passes the request on success or redirects the
requets to drawing the form again with messages in case of failure.
Hope this helps.
Regards
Felix