Is there a way to tell Tapestry to use:
validate="${validationText}"

so if getValidationText returns the string "required" it will act the same way 
as if you wrote: validate="required"?



-----Original Message-----
From: jackkuros...@w9z.org
Sent: Tuesday, May 24, 2011 2:47pm
To: "Tapestry users" <users@tapestry.apache.org>
Subject: Re: dynamic validation for required / not required

Thats helpful, but my problem is that I don't know the field id either, so I 
can't inject the field.  The fields are determined at run time (attributes that 
the user can add or remove) so it has to be flexible.

I supposed I could put every TextField in an IF statement where the IF has 
"required" and the ELSE doesn't, but that seems like I'm missing a better way 
to do it.

Jack

-----Original Message-----
From: "Thiago H. de Paula Figueiredo" <thiag...@gmail.com>

@Inject FieldValidatorSource and use its FieldValidator  
createValidators(Field field, String specification) method to generate a  
FieldValidator. Then create a FieldValidator getValidator() method using  
createValidators() and add t:validate="prop:validator" to your TextField.

Example (taken from  
http://tapestry.1045711.n5.nabble.com/Validation-based-on-condition-td2435565.html):

@Inject
private FieldValidatorSource source;

@InjectComponent
private Field yourField;

public FieldValidator getDynamicConstraints() {
        return source.createValidators(yourField, "required", null);
}



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




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

Reply via email to