DefaultFieldFactory does not get called for boolean properties

Here is a straightforward code -

        final Form storeForm = new Form();

        // FieldFactory for customizing the fields and adding validators
        storeForm.setFormFieldFactory(new StoreFieldFactory());
        storeForm.setItemDataSource(storeItem); // bind to POJO via BeanItem

        // Determines which properties are shown, and in which order:
        storeForm.setVisibleItemProperties(Arrays.asList(new String[] {
                "name", "description", "website", "aggregatorId",
                "verified", "active", "afsrcEnabled" }));

The StoreFieldFactory extends the DefaultFieldFactory.

Problem: I have many fields Store object that are booleans and hence have isActive(), isVerified() accessor methods. However, the DefaultFieldFactory does not get called for all these. Seems like it is looking for getActive and getVerified methods. Is this an enhancement to Vaadin or is there something else that I can do to get around it?

For me (at least in the Vaadin 6.5 branch), BeanItem and MethodProperty used here work just fine with “isXyz()” accessors, and I don’t see anything in Form that would skip boolean properties. Or do you have both getActive() and isActive() methods in the same class? In that case, I’m not sure which would be used.

If your item is a BeanItem, make sure you have not overridden (or put a breakpoint in) the wrong createField() method in DefaultFieldFactory - one is used for Table and the other for Form. You could directly implement FormFieldFactory instead of extending DefaultFieldFactory so that this is clear. Note also that some of the methods of DefaultFieldFactory are static.

You can also check that your item really has the property by calling Item.getItemPropertyIds() or Item.getItemProperty(“active”).

If you construct the item with an interface as the bean type, and your accessor method is in its superinterface, see
ticket #6063
(caused by a Java runtime library limitation, workaround in Vaadin 6.5 branch).