You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Charles Mason <ch...@gmail.com> on 2008/12/15 18:27:26 UTC

Custom Errors on Bean Edit Form

Hi All,

I have a fairly straight forward bean edit form on a page. Its a
create new user form so, I want to check the user doesn't already
exist and that the two password fields match. I do this validation in
the onSubmit method but I am struggling to use the error reporting
mechanism to inform the user.

How do I get access to the form component to generate the proper error
messages?


Charlie M

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Custom Errors on Bean Edit Form

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 15 Dec 2008 17:10:43 -0300, Olle Hallin <ol...@gmail.com>  
escreveu:

> For example like this (very simplified):
> @Component private Form myForm; // links to <t:form t:id="myForm">
>
> @Component private PasswordField password1; // links to <t:passwordfield
> t:id="password1">
>
> Object onSuccess() {
>   if (passwords unequal) {
>     myForm.recordError(password1, "Passwords does not match");
>     return null;
>   }
>   // else proceed with persisting the user
> }

The injection of the form and the field and the error message recording  
are correct, but your suggestion of using the onSuccess() method isn't  
correct

Validation should be done at onValidateForm() (VALIDATE_FORM event), not  
at the onSuccess (SUCCESS event). The SUCCESS event is meant to be fired  
only if validation was ok.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Custom Errors on Bean Edit Form

Posted by Olle Hallin <ol...@gmail.com>.
For example like this (very simplified):
@Component private Form myForm; // links to <t:form t:id="myForm">

@Component private PasswordField password1; // links to <t:passwordfield
t:id="password1">

Object onSuccess() {
  if (passwords unequal) {
    myForm.recordError(password1, "Passwords does not match");
    return null;
  }
  // else proceed with persisting the user
}

HTH
Olle


2008/12/15 Charles Mason <ch...@gmail.com>

> Hi All,
>
> I have a fairly straight forward bean edit form on a page. Its a
> create new user form so, I want to check the user doesn't already
> exist and that the two password fields match. I do this validation in
> the onSubmit method but I am struggling to use the error reporting
> mechanism to inform the user.
>
> How do I get access to the form component to generate the proper error
> messages?
>
>
> Charlie M
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Olle Hallin
Senior Java Developer and Architect
olle.hallin@crisp.se
www.crisp.se