Alexander, Thanks for the response. I am hoping to avoid Node Type definitions at this point and I don't think I can trust client side javascript validation. I see what I have to do, thanks. Is there any plan to incorporate some kind of validation functionality in the future?
-----Original Message----- From: Alexander Klimetschek [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 09, 2008 12:51 PM To: [email protected] Subject: Re: Data Validation On Tue, Dec 9, 2008 at 4:30 PM, Darrell Pittman <[EMAIL PROTECTED]> wrote: > If my post validation script is as you outline: > > if (validate(request)) { > String actualResourcePath = ....; > RequestDispatcher rd = request.getRequestDispatcher( > actualResourcePath, "sling/servlet/default"); > rd.forward(request, response); > } else { > // draw the form with messages > } > > How do I reload the edit.esp form but have the values populated by the > posted values instead of the currentNode values. Is the intent that in > the "// draw the form with messages" section I would forward to > edit.esp and edit.esp would have logic to know if it should populate > from the currentNode or from the request. Yes, I think that is what Felix meant. There is no generic form-html generator that knows how to include error messages in Sling, you have to write this logic yourself - but it is not that hard, especially with esp where you can simply have a properties object that is either the currentNode (fresh form) or a copy of the form parameters from the request (in case of error display). And finally I'd like to add two other (not necessarily complete) options for validation: a) you can put regexp-like constraints on properties in JCR (via node types), which would then work for use with Sling's default post servlet (see section 6.7.16 "Value Constraints" of the JCR spec [1] and node type definition in Jackrabbit [2]). b) if you don't assume a malicious user doing manual form posts, you can also put all the validation on the client with one of the many javascript frameworks. [1] http://jcp.org/en/jsr/detail?id=170 [2] http://jackrabbit.apache.org/node-types.html Regards, Alex -- Alexander Klimetschek [EMAIL PROTECTED]
