API Design (method call order)


i encountered that when working with forms together with custom FieldFactories, you need to code:

    setFormFieldFactory(new MyCustomFieldFactory());

if you code:

    setFormFieldFactory(new MyCustomFieldFactory());

things wont work. (DefaultFieldFactory will be used and people start wondering what happened with MyCustomFieldFactory).

IMO from an API standpoint, its not a good decission to mandate a method call order. But if you cant circumvent it, there should be at least proper documentation and something like a IllegalStateException on calling setFormFieldFactory() after setItemDataSource().

Interessed to hear oppinions on that.


I’m sure the documentation could be better – true of most APIs/platforms – but some things can’t be blocked easily to keep a programmer from himself. The setItemDataSource(item) method causes the ‘item’ to be processed at that point, so if you don’t have your custom field factory in place, it can’t be used then (when it returns from setItemDataSource, the fields have been created).

Since you were setting it after the fact, it was only in place for the next call to setItemDataSource…