You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joel Trunick <Jo...@SmartPrice.com> on 2003/02/27 22:42:45 UTC
Where to validate?
What's the appropriate place to validate between two ValidField's? If the
user has to enter their email twice, where do I check that they are the
same, and how do I tell the ValidField's that they aren't valid? I didn't
see an example.
Joel
RE: Where to validate?
Posted by "Howard M. Lewis Ship" <hl...@attbi.com>.
To do Form-level validations, you do them in the listener.
To indicate errors such as yours:
IValidationDelegate delegate = (IValidationDelegate)getValidationDelegate();
IFormComponent inputEmail2 = (IFormComponent)getComponent("inputEmail2");
delegate.setFormComponent(inputEmail2);
delegate.record("Email doesn't match", null, getEmail2());
--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/proposals/tapestry
> -----Original Message-----
> From: tsvetelin [mailto:tsvetelin.saykov@rushmore-digital.com]
> Sent: Friday, February 28, 2003 5:04 AM
> To: Tapestry users; Joel@SmartPrice.com
> Subject: RE: Where to validate?
>
>
> Hi Joel,
>
> You could do this in formSubmit method associated with your
> form or submit button. If you associate a method to submit
> button you should put it after 2 valid fields, because them
> must be rendered before the button.
>
> example:
>
> public void formSubmit(IRequestCycle cycle){
> chechFeildRelations();
> if(getFormDelegate().hasErrors())
> return;
>
> //do your custom code
> }
>
> private void chechFeildRelations(){
> String strEmail1 = getEmail1();
> String strEmail2 = getEmail2();
>
> if(!strEmail1.equals(strEmail2)){
> //book error in form delegate(you can
> associated error to one of 2 valid
> fields using one of the
> IValidationDelegate.records method
> }
> }
>
> -----Original Message-----
> From: Joel Trunick [mailto:Joel@SmartPrice.com]
> Sent: Thursday, February 27, 2003 11:43 PM
> To: 'Tapestry users'
> Subject: Where to validate?
>
>
>
>
> What's the appropriate place to validate between two
> ValidField's? If the user has to enter their email twice,
> where do I check that they are the same, and how do I tell
> the ValidField's that they aren't valid? I didn't see an example.
>
> Joel
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
RE: Where to validate?
Posted by tsvetelin <ts...@rushmore-digital.com>.
Hi Joel,
You could do this in formSubmit method associated with your form or submit
button. If you associate a method to submit button you should put it after 2
valid fields, because them must be rendered before the button.
example:
public void formSubmit(IRequestCycle cycle){
chechFeildRelations();
if(getFormDelegate().hasErrors())
return;
//do your custom code
}
private void chechFeildRelations(){
String strEmail1 = getEmail1();
String strEmail2 = getEmail2();
if(!strEmail1.equals(strEmail2)){
//book error in form delegate(you can associated error to one of 2 valid
fields using one of the IValidationDelegate.records method
}
}
-----Original Message-----
From: Joel Trunick [mailto:Joel@SmartPrice.com]
Sent: Thursday, February 27, 2003 11:43 PM
To: 'Tapestry users'
Subject: Where to validate?
What's the appropriate place to validate between two ValidField's? If the
user has to enter their email twice, where do I check that they are the
same, and how do I tell the ValidField's that they aren't valid? I didn't
see an example.
Joel