Example usage for com.vaadin.ui DateField DateField

List of usage examples for com.vaadin.ui DateField DateField

Introduction

In this page you can find the example usage for com.vaadin.ui DateField DateField.

Prototype

public DateField() 

Source Link

Document

Constructs an empty DateField with no caption.

Usage

From source file:uk.q3c.krail.core.ui.DefaultDataTypeToUI.java

License:Apache License

@Override
public AbstractField componentFor(Class<?> dataType) {
    if (dataType.equals(Date.class)) {
        return new DateField();
    }//from   ww  w .  j a va  2  s . c  om
    if (dataType.equals(boolean.class) || dataType.equals(Boolean.class)) {
        return new CheckBox();
    }
    return new TextField();
}

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  av a2s.c  om*/
            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
        }
    }

}