Package com.vaadin.data.fieldgroup

Examples of com.vaadin.data.fieldgroup.FieldGroup


*/
public class FieldGroupTest {

    @Test
    public void setReadOnly_readOnlyAndNoDataSource_fieldIsReadOnly() {
        FieldGroup fieldGroup = new FieldGroup();

        TextField field = new TextField();
        fieldGroup.bind(field, "property");

        fieldGroup.setReadOnly(true);

        Assert.assertTrue("Field is not read only", field.isReadOnly());
    }
View Full Code Here


        Assert.assertTrue("Field is not read only", field.isReadOnly());
    }

    @Test
    public void setReadOnly_writableAndNoDataSource_fieldIsWritable() {
        FieldGroup fieldGroup = new FieldGroup();

        TextField field = new TextField();
        fieldGroup.bind(field, "property");

        fieldGroup.setReadOnly(false);

        Assert.assertFalse("Field is not writable", field.isReadOnly());
    }
View Full Code Here

        // Create one
        MyForm form = new MyForm();

        // Now create a binder that can also creates the fields
        // using the default field factory
        FieldGroup binder = new FieldGroup(item);
        binder.bindMemberFields(form);

        assertTrue(form.description.getValue().equals("This is a description"));
    }
View Full Code Here

            }
        }

        MyForm form = new MyForm();

        FieldGroup binder = new FieldGroup(item);
        binder.bindMemberFields(form);

        assertTrue("Sparrow".equals(form.lastName.getValue()));
    }
View Full Code Here

            }
        }

        MyForm form = new MyForm();

        FieldGroup binder = new FieldGroup(item);
        binder.bindMemberFields(form);

        assertTrue("Jack".equals(form.firstName.getValue()));
    }
View Full Code Here

            }
        }

        MyForm form = new MyForm();

        FieldGroup binder = new FieldGroup(item);
        binder.bindMemberFields(form);

        assertTrue("This".equals(form.firstName.getValue()));
    }
View Full Code Here

    protected void setup(VaadinRequest request) {
        // Create the layout
        MyFormLayout myFormLayout = new MyFormLayout();

        // Create a field group and use it to bind the fields in the layout
        FieldGroup fieldGroup = new FieldGroup(new BeanItem<Notice>(new Notice(
                "John", "Doe", "")));
        fieldGroup.bindMemberFields(myFormLayout);

        addComponent(myFormLayout);
    }
View Full Code Here

    protected void init(VaadinRequest request) {
        VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        FieldGroup fieldGroup = new BeanFieldGroup<Person>(Person.class);

        // We need an item data source before we create the fields to be able to
        // find the properties, otherwise we have to specify them by hand
        fieldGroup.setItemDataSource(new BeanItem<Person>(new Person("John",
                "Doe", 34)));

        // Loop through the properties, build fields for them and add the fields
        // to this root
        for (Object propertyId : fieldGroup.getUnboundPropertyIds()) {
            layout.addComponent(fieldGroup.buildAndBind(propertyId));
        }
    }
View Full Code Here

    }

    private void updateCalendarEventForm(CalendarEvent event) {
        BeanItem<CalendarEvent> item = new BeanItem<CalendarEvent>(event);
        scheduleEventFieldLayout.removeAllComponents();
        scheduleEventFieldGroup = new FieldGroup();
        initFormFields(scheduleEventFieldLayout, event.getClass());
        scheduleEventFieldGroup.setBuffered(true);
        scheduleEventFieldGroup.setItemDataSource(item);
    }
View Full Code Here

        TextField textField = new TextField("BigDecimal field");
        textField.setImmediate(true);
        textField.setValue("12");
        formLayout.addComponent(textField);

        final FieldGroup fieldGroup = new FieldGroup(beanItem);
        fieldGroup.bind(textField, "decimal");

        Button setValue = new Button("Set value to 15,2", new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                ((TextField) fieldGroup.getField("decimal")).setValue("15,2");
            }
        });

        Button button = new Button("Commit");
        button.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                try {
                    fieldGroup.commit();
                    log("Commit ok. Property value: "
                            + fieldGroup.getItemDataSource()
                                    .getItemProperty("decimal").getValue());
                } catch (FieldGroup.CommitException e) {
                    log("Commit failed: " + e.getMessage());
                }
            }
View Full Code Here

TOP

Related Classes of com.vaadin.data.fieldgroup.FieldGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.