You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Hensley, Richard" <Ri...@McKesson.com> on 2004/10/13 00:57:54 UTC
Using Validator and Validation Delegate to high light fields
I'm using IValidationDelegate to render special css classes onto my required
fields with the following code:
public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component, IValidator validator) {
if (isInError(component)) {
writer.attribute("class", "field-error");
}
else if (validator != null && validator.isRequired()) {
writer.attribute("class", "field-required");
}
}
What I really would like to do is do something like the following:
public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
IFormComponent component, IValidator validator) {
if (isInError(component)) {
writer.attribute("class", "field-error");
}
else if (validator != null && validator.isRequired() && /* the
component value is blank */) {
writer.attribute("class", "field-required-blank");
}
else if (validator != null && validator.isRequired()) {
writer.attribute("class", "field-required");
}
}
Any clues where to start?
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Using Validator and Validation Delegate to high light fields
Posted by Bryan Lewis <br...@maine.rr.com>.
This is a bit ugly, but how about:
if (validator != null && validator.isRequired()
&& component instanceof AbstractTextField
&& ((AbstractTextField)component).readValue() == null)
----- Original Message -----
From: "Hensley, Richard" <Ri...@McKesson.com>
To: "'Tapestry users'" <ta...@jakarta.apache.org>
Sent: Tuesday, October 12, 2004 6:57 PM
Subject: Using Validator and Validation Delegate to high light fields
> I'm using IValidationDelegate to render special css classes onto my
required
> fields with the following code:
>
> public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
> IFormComponent component, IValidator validator) {
> if (isInError(component)) {
> writer.attribute("class", "field-error");
> }
> else if (validator != null && validator.isRequired()) {
> writer.attribute("class", "field-required");
> }
> }
>
> What I really would like to do is do something like the following:
>
> public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
> IFormComponent component, IValidator validator) {
> if (isInError(component)) {
> writer.attribute("class", "field-error");
> }
> else if (validator != null && validator.isRequired() && /* the
> component value is blank */) {
> writer.attribute("class", "field-required-blank");
> }
> else if (validator != null && validator.isRequired()) {
> writer.attribute("class", "field-required");
> }
> }
>
> Any clues where to start?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org