You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/01/08 16:16:10 UTC
DO NOT REPLY [Bug 25991] New: -
Validate a single field
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25991>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25991
Validate a single field
Summary: Validate a single field
Product: Commons
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: Enhancement
Priority: Other
Component: Validator
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: scott.culbertson@convergys.com
We are using the validator framework for a Swing application and need to be able
to validate a single field on the bean (our Model). It is too expensive to
validate the entire bean every time when we only care about a single field (for
example validating a filed when it loses focus).
What I need is a new validate method on the Validator class that takes the field
name as an argument and returns a ValidatorResult. I can't extend the Validator
class and write my own because the validateField method is private.
The two solutions I have thought of are to either add a validate method on the
Validator class, or to make the validateField method protected (or protected
final) instead of private (so I can do what I need in a subclass).
Here is a possible implementation of the new validate (mostly a cut and paste
from the existing method)to give you an idea what I need:
public ValidatorResult validate(String fieldName) throws ValidatorException
{
ValidatorResults results = new ValidatorResults();
Locale locale = (Locale) this.getParameterValue(LOCALE_PARAM);
if (locale == null) {
locale = Locale.getDefault();
}
this.setParameter(VALIDATOR_PARAM, this);
Form form = this.resources.getForm(locale, this.formName);
if (form != null) {
Field field = form.getField(fieldName);
if (field == null) {
throw new ValidatorException("Unable to validate Field " + fieldName
+ ". Field not found.");
}
if ((field.getPage() <= page) && (field.getDepends() != null)) {
this.validateField(field, results);
}
}
return results.getValidatorResult(fieldName);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org