You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Joshua Oransky <ca...@gmail.com> on 2008/10/17 18:12:06 UTC
Error Messaging/Validation
Is there any type of error messaging or validation in Sling? I want to
be able to give my users information about whether they entered their
data correctly, and intercept it before it's saved if they have not.
It would also be nice to simply be able to add messages to some sort
of stack so that the resulting page they end up on can display
information about the last content edit.
I tried simply adding the message as a hidden field and then getting
the parameter in the request, but if I use the :redirect parameter,
predictably I get a full redirect, which loses any of these additional
params.
I saw a few messages in the mailing list about Validation, but I can't
find anything specific in the docs or examples on how to implement it.
-Josh
Re: Error Messaging/Validation
Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Oct 20, 2008 at 8:12 AM, Felix Meschberger <fm...@gmail.com> wrote:
> Alexander Klimetschek schrieb:
>> ....Is there a taglib tag for doing this directly in JSPs? If not,
>> might be useful and simpler than to remember these lines and the
>> correct request dispatcher options. Something like <sling:forward />,
>> similar to sling:include.
>
> Yes, this is a TODO. And I think at least one form of
> SlingScriptHelper.forward method should also be provided.
Note that this is being handled in SLING-703 and the related issues.
-Bertrand
Re: Error Messaging/Validation
Posted by Carsten Ziegeler <cz...@apache.org>.
Felix Meschberger wrote:
> Hi,
>
> Alexander Klimetschek schrieb:
>> On Sun, Oct 19, 2008 at 10:20 PM, Felix Meschberger <fm...@gmail.com> wrote:
>>> RequestDispatcher rd = request.getRequestDispatcher(
>>> request.getResource(),
>>> new
>>> RequestDispatcherOptions(ServletResolverConstants.DEFAULT_SERVLET_NAME)
>>> );
>>> rd.forward(request, response);
>>>
>>> For the forward to succeed you need a current snapshot build of the
>>> engine module (forward has just been added last week).
>> Cool! Is there a taglib tag for doing this directly in JSPs? If not,
>> might be useful and simpler than to remember these lines and the
>> correct request dispatcher options. Something like <sling:forward />,
>> similar to sling:include.
>
> Yes, this is a TODO. And I think at least one form of
> SlingScriptHelper.forward method should also be provided.
>
+1
Carsten
--
Carsten Ziegeler
cziegeler@apache.org
Re: Error Messaging/Validation
Posted by Felix Meschberger <fm...@gmail.com>.
Hi,
Alexander Klimetschek schrieb:
> On Sun, Oct 19, 2008 at 10:20 PM, Felix Meschberger <fm...@gmail.com> wrote:
>> RequestDispatcher rd = request.getRequestDispatcher(
>> request.getResource(),
>> new
>> RequestDispatcherOptions(ServletResolverConstants.DEFAULT_SERVLET_NAME)
>> );
>> rd.forward(request, response);
>>
>> For the forward to succeed you need a current snapshot build of the
>> engine module (forward has just been added last week).
>
> Cool! Is there a taglib tag for doing this directly in JSPs? If not,
> might be useful and simpler than to remember these lines and the
> correct request dispatcher options. Something like <sling:forward />,
> similar to sling:include.
Yes, this is a TODO. And I think at least one form of
SlingScriptHelper.forward method should also be provided.
Regards
Felix
Re: Error Messaging/Validation
Posted by Alexander Klimetschek <ak...@day.com>.
On Sun, Oct 19, 2008 at 10:20 PM, Felix Meschberger <fm...@gmail.com> wrote:
> RequestDispatcher rd = request.getRequestDispatcher(
> request.getResource(),
> new
> RequestDispatcherOptions(ServletResolverConstants.DEFAULT_SERVLET_NAME)
> );
> rd.forward(request, response);
>
> For the forward to succeed you need a current snapshot build of the
> engine module (forward has just been added last week).
Cool! Is there a taglib tag for doing this directly in JSPs? If not,
might be useful and simpler than to remember these lines and the
correct request dispatcher options. Something like <sling:forward />,
similar to sling:include.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: Error Messaging/Validation
Posted by Felix Meschberger <fm...@gmail.com>.
Hi,
Currently we do not have a proper validation framework in yet. There
have been some discussions, but with no outcome.
There is a possible solution, though: register a POST script/servlet for
your resource type, which gets the POST requests instead of the default
POST servlet.
In the script you validate the input and return an error response in
case of validation failures. In case of validation success you would
forward the request to the default post servlet using the Request
Dispatcher:
RequestDispatcher rd = request.getRequestDispatcher(
request.getResource(),
new
RequestDispatcherOptions(ServletResolverConstants.DEFAULT_SERVLET_NAME)
);
rd.forward(request, response);
For the forward to succeed you need a current snapshot build of the
engine module (forward has just been added last week).
The point with the request dispatcher is, that you forward the request
for processing with overwritten resource type for which the default
Sling Post Servlet is registered.
Hope this helps.
Regards
Felix
Joshua Oransky schrieb:
> Is there any type of error messaging or validation in Sling? I want to
> be able to give my users information about whether they entered their
> data correctly, and intercept it before it's saved if they have not. It
> would also be nice to simply be able to add messages to some sort of
> stack so that the resulting page they end up on can display information
> about the last content edit.
>
> I tried simply adding the message as a hidden field and then getting the
> parameter in the request, but if I use the :redirect parameter,
> predictably I get a full redirect, which loses any of these additional
> params.
>
> I saw a few messages in the mailing list about Validation, but I can't
> find anything specific in the docs or examples on how to implement it.
>
> -Josh
>
Re: Error Messaging/Validation
Posted by Renaud Richardet <re...@apache.org>.
hi Joshua,
There is validation in Sling, for example try to put a @TypeHint Integer and
then POST something different than an Integer. But there is nothing yet like
@MaxLength or @ErrorMsg (would be cool, though).
Maybe you could do the validation on the client with javascript. I had good
results with the jQuery validation plugin [1], you can see the result in the
small app "Form.ation" [2].
Pros: very simple to set up and lets you customize error messages, etc.
Cons: depends on javascript, no validation on your repository
HTH, Renaud
[1] http://jquery.bassistance.de/validate/demo/
[2] http://code.google.com/p/formation-sling/
Renaud Richardet -- renaud [at] apache.org -- www.oslutions.com
On Fri, Oct 17, 2008 at 6:12 PM, Joshua Oransky <ca...@gmail.com> wrote:
> Is there any type of error messaging or validation in Sling? I want to be
> able to give my users information about whether they entered their data
> correctly, and intercept it before it's saved if they have not. It would
> also be nice to simply be able to add messages to some sort of stack so that
> the resulting page they end up on can display information about the last
> content edit.
>
> I tried simply adding the message as a hidden field and then getting the
> parameter in the request, but if I use the :redirect parameter, predictably
> I get a full redirect, which loses any of these additional params.
>
> I saw a few messages in the mailing list about Validation, but I can't find
> anything specific in the docs or examples on how to implement it.
>
> -Josh
>