You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Dirk Gabler <di...@epost.de> on 2004/12/15 17:59:54 UTC

Handling of validation of indexed properties: Change proposal

Hi,

in my current project I had to meet the two following requirements:

- Validation of indexed properties has to be done for all the beans in a
collection, even if one failes

- The validation result of an indexed property has to contain the index
also, e.g. masterbean.detailbean[1].property

These are the changes I've done and I would be happy about feedback from
the developers:

Field.java (validate()-Method)
------------------------------

// PATCH-START
// REASON: 
// We want to validate all fields in the array, even if one failes
// ORIGINAL:
// if (!good) {

if (!good && (fieldNumber == numberOfFieldsToValidate-1)) {
    return allResults;
}

// PATCH-END



ValidatorAction.java (executeValidationMethod()-method)
--------------------------------------------------------

if (!valid || (valid && !onlyReturnErrors(params))) {
// PATCH-START
// REASON: 
// If it's an indexed field, we put the indexed key 
// into the error list, which means
// e.g. master.detail[0].prop instead of master.detail[].prop

if (field.isIndexed()) {
    Field indexedField = (Field)paramValues[this.methodParameterList.indexOf(Validator.FIELD_PARAM)];
    results.add(indexedField, this.name, valid, result);
} else {
    results.add(field, this.name, valid, result);                    
}
// PATCH-END

}

Thanks in advance,
Dirk


________________________________________
http://www.epost.de - das Kommunikationsportal der Deutschen Post



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org