JIDE 3.5.15

com.jidesoft.validation
Interface RowValidator

All Superinterfaces:
EventListener

public interface RowValidator
extends EventListener

Validator is an interface for validating a row in table.


Method Summary
 ValidationResult validating(RowValidationObject vo)
          Validates the value in the RowValidationObject.
 

Method Detail

validating

ValidationResult validating(RowValidationObject vo)
Validates the value in the RowValidationObject.

The event has the row index and the JTable which is the source. The implementation of this method should validate if the row is valid. If the row is valid, simply return ValidationResult.OK. Otherwise, constructs a ValidationResult and provide the id and message. You can also return RowValidationResult which has an array of invalid column indices. Usually when you validate a row, you will be able to figure out values in one or several columns are invalid. You can pass them to RowValidationResult and return it. Listeners for the RowValidator can decide to display some error indications to indicate which cells are invalid.

Although ValidationResult allows user to specify the fail behavior such as FAIL_BEHAVIOR_REVERT, FAIL_BEHAVIOR_RESET or FAIL_BEHAVIOR_PERSIST, in the case of RowValidator, none of the options make sense so the fail behavior you set will be ignored. So it is better you process the error right there in the validating method. See the code below for an example.

 public ValidationResult validating(RowValidationObject vo) {
     boolean valid = ...; // validate the row
     if (valid) {
         return null;
     }
     else {
         PortingUtils.notifyUser();  // notify the user
         table.editCellAt(vo.getRowIndex(), 5); // force editing mode in case this is the invalid cell.
         return new RowValidationResult(false, new int[]{5});
     }
 } 

Please note all the RowValidators added to a JideTable will be used for to validate any rows.

Parameters:
vo - the ValidationObject
Returns:
ValidationResult

JIDE 3.5.15