CustomLayout and Form

Hello,

i am new at vaadin and try to use a Form with CustomLayout.
Therefore i created a html-template and use this within the CustomLayout.class.
The Form is shown with my HTML-Template. But if i want to validate field and show validation errors, the inputfield are not read from vaadin.
I looked also in the Example “FormAdvancedLayoutExample”. Is the FieldValidation with the ErrorMessages also available with CustomLayouts?
Also required Fields are not market with a red star.
Did I forgot something?

Here’s my code:


public class CustomSignUpPage extends VerticalLayout {


    User user;

    public CustomSignUpPage() {
        setMargin(true);
        user = new User();

        final Form signUpForm = new Form(new CustomLayout("signuppage"));

        signUpForm.setFormFieldFactory(new PersonFieldFactory());
        signUpForm.setItemDataSource(new BeanItem<User>(user));
        signUpForm.setVisibleItemProperties(Arrays.asList(new String[]{
                                                                "firstname",
                                                                "lastname",
                                                                "email"}));
        signUpForm.setValidationVisible(true);

        signUpForm.setWriteThrough(false); // we want explicit 'apply'
        signUpForm.setInvalidCommitted(false); // no invalid values in datamodel


        Button.ClickListener buttonClicked = new Button.ClickListener() {
            @Override
            public void buttonClick(final Button.ClickEvent event) {
                try {
                    signUpForm.commit();
                } catch (Exception e) {
                    //getWindow().showNotification(e.getMessage(), 3);
                }
                Window.Notification n = new Window.Notification("POJO state", Window.Notification.TYPE_TRAY_NOTIFICATION);
                n.setPosition(Window.Notification.POSITION_CENTERED);
                n.setDescription(
                           "First name: " + user.getFirstname()
                        + "<br/>Last name: " + user.getLastname()
                        + "<br/>Email: " + user.getEmail());
                getWindow().showNotification(n);

                Cluster myCluster = HFactory.getOrCreateCluster("Test Cluster", "localhost:9160");
                Keyspace ksp = HFactory.createKeyspace("testapp", myCluster);
                ColumnFamilyTemplate<String, String> template =
                        new ThriftColumnFamilyTemplate<String, String>(ksp,
                                "Users",
                                StringSerializer.get(),
                                StringSerializer.get());
                try {
                    ColumnFamilyResult<String, String> res = template.queryColumns("user0001");
                    String value = res.getString("name");
                    String lastName = res.getString("firstname");
                    String email = res.getString("email");
                    getWindow().showNotification(value + " " + lastName + " with " + email + " found");
                } catch (HectorException e) {
                    getWindow().showNotification(e.getMessage());
                }
            }
        };
        addComponent(signUpForm);
        Button signUpButton = new Button("SIGN UP!");
        signUpButton.setStyleName("btn btn-large btn-primary");
        signUpForm.addField("signup", signUpButton);
        signUpButton.addListener(buttonClicked);
    }

    private class PersonFieldFactory extends DefaultFieldFactory {

        private static final String COMMON_FIELD_WIDTH = "12em";

        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            Field theField;
            if ("password".equals(propertyId)) {
                theField = createPasswordField(propertyId);
            } else {
                theField = super.createField(item, propertyId, uiContext);
            }

            if ("firstname".equals(propertyId)) {
                TextField tf = (TextField) theField;
                tf.setRequired(true);
                tf.setRequiredError("Please enter a First Name");
                tf.setWidth(COMMON_FIELD_WIDTH);
                tf.addValidator(new StringLengthValidator(
                        "First Name must be 3-25 characters", 3, 25, false));
            } else if ("lastname".equals(propertyId)) {
                TextField tf = (TextField) theField;
                tf.setRequired(true);
                tf.setRequiredError("Please enter a Last Name");
                tf.setWidth(COMMON_FIELD_WIDTH);
                tf.addValidator(new StringLengthValidator(
                        "Last Name must be 3-50 characters", 3, 50, false));
            } else if ("password".equals(propertyId)) {
                PasswordField pf = (PasswordField) theField;
                pf.setRequired(true);
                pf.setRequiredError("Please enter a password");
                pf.setWidth("10em");
                pf.addValidator(new StringLengthValidator(
                        "Password must be 6-20 characters", 6, 20, false));
            }
            return theField;
        }

        private PasswordField createPasswordField(Object propertyId) {
            PasswordField pf = new PasswordField();
            pf.setCaption(DefaultFieldFactory
                    .createCaptionByPropertyId(propertyId));
            return pf;
        }
    }
}