/** * Adds a validator to the input field. * <p> * The validator will only be added if the field is a {@link Input} component. * </p> * * @param validator the validator to add. */ public void addValidator(final FieldValidator validator) { WComponent labelField = findComponentForLabel(field); if (labelField instanceof Input) { ((Input) labelField).addValidator(validator); } }
/** * Sets whether this field is mandatory. * <p> * The mandatory flag will only be set if the field is a {@link Input} component or {@link WFieldSet}. * </p> * * @param mandatory true for mandatory, false for optional * @param errorMessage the error message to display on validation error. * @deprecated set mandatory directly on the required component. */ @Deprecated public void setMandatory(final boolean mandatory, final String errorMessage) { WComponent labelField = findComponentForLabel(field); if (labelField instanceof Mandatable) { ((Input) labelField).setMandatory(mandatory, errorMessage); } else if (labelField instanceof WFieldSet) { ((WFieldSet) labelField).setMandatory(mandatory, errorMessage); } }
WComponent theField = findComponentForLabel(container.getChildAt(i));
WComponent labelField = findComponentForLabel(field);