List of usage examples for com.vaadin.ui TextArea addFocusListener
@Override
public Registration addFocusListener(FocusListener listener)
From source file:zm.hashcode.mshengu.app.util.validation.OnSubmitValidationHelper.java
public void doValidation() { TextField textField = new TextField(); TextArea textArea = new TextArea(); DateField dateField = new DateField(); ComboBox comboBox = new ComboBox(); for (Field o : fields) { String currentMessage = ""; try {//from w ww .j a v a 2s. c o m if (o instanceof TextField) { textField = (TextField) o; textField.validate(); } else if (o instanceof TextArea) { textArea = (TextArea) o; textArea.validate(); } else if (o instanceof DateField) { dateField = (DateField) o; dateField.validate(); } else if (o instanceof ComboBox) { comboBox = (ComboBox) o; comboBox.validate(); } } catch (Validator.InvalidValueException x) { //works with vaadin required currentMessage = x.getMessage(); if (o instanceof TextField) { textField.setStyleName("invalid"); } else if (o instanceof TextArea) { textArea.setStyleName("invalid"); } else if (o instanceof DateField) { dateField.setStyleName("invalid"); } else if (o instanceof ComboBox) { comboBox.setStyleName("invalid"); } } finally { if (o instanceof TextField) { textField.addFocusListener( new LabelErrorMessageManipulator(textField, errorLabel, currentMessage)); //custom focus handler for displaying error message on a labe when you focus on an errored Textfield } else if (o instanceof TextArea) { textArea.addFocusListener( new LabelErrorMessageManipulator(textArea, errorLabel, currentMessage)); //custom focus handler for displaying error message on a labe when you focus on an errored Textfield } else if (o instanceof DateField) { dateField.addFocusListener( new LabelErrorMessageManipulator(dateField, errorLabel, currentMessage)); //custom focus handler for displaying error message on a labe when you focus on an errored Textfield } else if (o instanceof ComboBox) { comboBox.addFocusListener( new LabelErrorMessageManipulator(comboBox, errorLabel, currentMessage)); //custom focus handler for displaying error message on a labe when you focus on an errored Textfield } } if (o instanceof TextField) { textField.addBlurListener(new LabelErrorMessageManipulator(textField, errorLabel, currentMessage)); //custom blur handler for displaying error message on a labe when you blur on an errored Textfield } else if (o instanceof TextArea) { textArea.addBlurListener(new LabelErrorMessageManipulator(textArea, errorLabel, currentMessage)); //custom blur handler for displaying error message on a labe when you blur on an errored Textfield } else if (o instanceof DateField) { dateField.addBlurListener(new LabelErrorMessageManipulator(dateField, errorLabel, currentMessage)); //custom blur handler for displaying error message on a labe when you blur on an errored Textfield } else if (o instanceof ComboBox) { comboBox.addBlurListener(new LabelErrorMessageManipulator(comboBox, errorLabel, currentMessage)); //custom blur handler for displaying error message on a labe when you blur on an errored Textfield } } }