svn changeset:7369/svn branch:6.0
* {@link Validator.InvalidValueException} if the given value is not valid by
* its standards.
*
+ * Validators should not have side effects on other objects as they can be
+ * called from Paintable.paint().
+ *
* @author IT Mill Ltd.
* @version
* @VERSION@
throw new Validator.InvalidValueException("Username "
+ value + " already in use");
}
- usernames.add(value);
}
});
username.addListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
TextField tf = (TextField) event.getProperty();
tf.validate();
- if (tf.isValid()) {
- addComponent(new Label("Added " + tf.getValue()
- + " to usernames"));
- }
+ usernames.add(tf.getValue());
+ addComponent(new Label("Added " + tf.getValue()
+ + " to usernames"));
}
});
*/
public boolean isValid() {
- if (isRequired()) {
- if (isEmpty()) {
+ if (isEmpty()) {
+ if (isRequired()) {
return false;
- }
- } else {
- if (isEmpty()) {
+ } else {
return true;
}
}
*/
public void validate() throws Validator.InvalidValueException {
- if (isRequired()) {
- if (isEmpty()) {
+ if (isEmpty()) {
+ if (isRequired()) {
throw new Validator.EmptyValueException(requiredError);
+ } else {
+ return;
}
}