to.etc.domui.component.form
Interface ControlFactory

All Known Implementing Classes:
ControlFactoryDate, ControlFactoryEnumAndBool, ControlFactoryMoney, ControlFactoryRelationCombo, ControlFactoryRelationLookup, ControlFactoryString, ControlFactoryTextArea

public interface ControlFactory

A factory which creates the correct EDITING control to edit a property, specified by the property's PropertyMetaModel. The DomApplication will contain a list of ControlFactories. When an edit control is needed this list is obtained and each ControlFactory in it has it's accepts() method called. This returns a "score" for each control factory. The first factory with the highest score (which must be > 0) will be used to create the control. If no factory returns a > 0 score a control cannot be created which usually results in an exception.

Author:
Frits Jalvingh Created on Dec 8, 2008

Field Summary
static ControlFactory BOOLEAN_AND_ENUM_CF
           
static ControlFactory DATE_CF
           
static ControlFactory RELATION_COMBOBOX_CF
          Factory for UP relations.
static ControlFactory RELATION_LOOKUP_CF
           
static ControlFactory STRING_CF
          This is a fallback factory; it accepts anything and shows a String edit component for it.
static ControlFactory TEXTAREA_CF
           
 
Method Summary
 int accepts(PropertyMetaModel<?> pmm, boolean editable, java.lang.Class<?> controlClass, java.lang.Object context)
          This must return a +ve value when this factory accepts the specified property; the returned value is an eagerness score.
<T> ControlFactoryResult
createControl(IReadOnlyModel<?> model, PropertyMetaModel<T> pmm, boolean editable, java.lang.Class<?> controlClass, java.lang.Object context)
          This MUST create all nodes necessary for a control to edit the specified item.
 

Field Detail

TEXTAREA_CF

static final ControlFactory TEXTAREA_CF

STRING_CF

static final ControlFactory STRING_CF
This is a fallback factory; it accepts anything and shows a String edit component for it. It hopes that the Text control can convert the string input value to the actual type using the registered Converters. This is also the factory for regular Strings.


BOOLEAN_AND_ENUM_CF

static final ControlFactory BOOLEAN_AND_ENUM_CF

DATE_CF

static final ControlFactory DATE_CF

RELATION_COMBOBOX_CF

static final ControlFactory RELATION_COMBOBOX_CF
Factory for UP relations. This creates a combobox input if the property is an UP relation and has combobox properties set.


RELATION_LOOKUP_CF

static final ControlFactory RELATION_LOOKUP_CF
Method Detail

accepts

int accepts(@Nonnull
            PropertyMetaModel<?> pmm,
            boolean editable,
            @Nullable
            java.lang.Class<?> controlClass,
            @Nullable
            java.lang.Object context)
This must return a +ve value when this factory accepts the specified property; the returned value is an eagerness score. The factory returning the highest eagerness wins.

Parameters:
pmm -
editable -
controlClass - When set the control factory *must* be able to return a component which is assignment-compatible with this class type. If it cannot it MUST refuse to create the control.
context - TODO
Returns:

createControl

<T> ControlFactoryResult createControl(@Nonnull
                                       IReadOnlyModel<?> model,
                                       @Nonnull
                                       PropertyMetaModel<T> pmm,
                                       boolean editable,
                                       @Nullable
                                       java.lang.Class<?> controlClass,
                                       @Nullable
                                       java.lang.Object context)
This MUST create all nodes necessary for a control to edit the specified item. The nodes must be added to the container; this must return a ModelBinding to bind and unbind a value to the control created.

Parameters:
pmm -
editable -
controlClass - When set the control factory *must* return a component which is assignment-compatible with this class type. When this method is called it has already (by it's accept method) told us it can, so not creating the proper type is not an option.
context - TODO
container -
Returns: