to.etc.domui.component.form
Class GenericFormBuilder

java.lang.Object
  extended by to.etc.domui.component.form.FormBuilderBase
      extended by to.etc.domui.component.form.GenericFormBuilder
Direct Known Subclasses:
GenericTableFormBuilder

public abstract class GenericFormBuilder
extends FormBuilderBase

Encapsulates basic actions that can be done with all form builder implementations, and delegates the actual parts that require layout decisions to the actual implementation.

Author:
Frits Jalvingh Created on Aug 13, 2009

Field Summary
 
Fields inherited from class to.etc.domui.component.form.FormBuilderBase
LOG
 
Constructor Summary
GenericFormBuilder()
          Default ctor.
GenericFormBuilder(java.lang.Class<T> clz, IReadOnlyModel<T> mdl)
          Create one primed with a model and class.
GenericFormBuilder(T instance)
          
 
Method Summary
abstract  void addContent(NodeBase label, NodeBase[] control, boolean editable)
           
 void addContent(NodeBase label, NodeBase control, boolean editable)
           
 void addContent(java.lang.String label, NodeBase control, boolean editable)
           
protected abstract  void addControl(NodeBase label, NodeBase labelnode, NodeBase[] list, boolean mandatory, boolean editable, PropertyMetaModel<?> pmm)
           
protected abstract  void addControl(java.lang.String label, NodeBase labelnode, NodeBase[] list, boolean mandatory, boolean editable, PropertyMetaModel<?> pmm)
          This is the actual workhorse doing the per-builder actual placement and layouting of a {control, label} pair.
 IControl<?> addDisplayProp(java.lang.String name)
          Add a display-only field for the specified property.
 IControl<?> addDisplayProp(java.lang.String name, java.lang.String label)
          Add an input for the specified property just as addProp(String, String), only this input won't be editable (ever).
<V,T extends NodeBase & IDisplayControl<V>>
IControl<V>
addDisplayProp(java.lang.String propertyname, T ctl)
           
 IControl<?>[] addDisplayProps(java.lang.String... names)
          Add the specified properties to the form as display-only properties, in the current mode.
 void addLabelAndControl(Label label, java.lang.String errorLocation, NodeBase control, boolean mandatory)
          Add a fully manually specified label and control to the layout.
 void addLabelAndControl(java.lang.String label, NodeBase control, boolean mandatory)
          Add a fully manually specified label and control to the layout.
protected abstract  IControl<?>[] addListOfProperties(boolean editable, java.lang.String... names)
          Handle placement of a list of property names, all obeying the current mode in effect.
 IControl<?> addProp(java.lang.String name)
          Add an input for the specified property.
 IControl<?> addProp(java.lang.String name, boolean editable)
          Add an input for the specified property.
 IControl<?> addProp(java.lang.String name, boolean editable, boolean mandatory)
          Add an input for the specified property.
 IControl<?> addProp(java.lang.String name, java.lang.String label)
          Add an input for the specified property.
 IControl<?> addProp(java.lang.String name, java.lang.String label, boolean editable, boolean mandatory)
          Add an input for the specified property.
<V,T extends NodeBase & IInputNode<V>>
IControl<V>
addProp(java.lang.String name, java.lang.String label, T ctl)
          Add a user-specified control for a given property.
<V,T extends NodeBase & IInputNode<V>>
IControl<V>
addProp(java.lang.String propertyname, T ctl)
          Add a user-specified control for a given property.
 void addPropertyAndControl(java.lang.String propertyName, NodeBase nb, boolean mandatory)
          This adds a fully user-specified control for a given property with it's default label, without creating any binding.
protected  IControl<?> addPropertyControl(java.lang.String name, java.lang.String label, PropertyMetaModel<?> pmm, boolean editable)
           
 IControl<?>[] addProps(java.lang.String... names)
          Add the specified properties to the form, in the current mode.
 
Methods inherited from class to.etc.domui.component.form.FormBuilderBase
createControlFor, createControlFor, getBindings, getBuilder, getClassMeta, getContext, getControlLabelFactory, getCurrentInputClass, getModel, resolveProperty, rights, setBindings, setClassModel, setContext, setControlLabelFactory, setInstance, setMetaModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericFormBuilder

public GenericFormBuilder()
Default ctor.


GenericFormBuilder

public GenericFormBuilder(java.lang.Class<T> clz,
                          IReadOnlyModel<T> mdl)
Create one primed with a model and class.

Type Parameters:
T -
Parameters:
clz -
mdl -

GenericFormBuilder

public GenericFormBuilder(T instance)

Type Parameters:
T -
Parameters:
instance -
Method Detail

addControl

protected abstract void addControl(java.lang.String label,
                                   NodeBase labelnode,
                                   NodeBase[] list,
                                   boolean mandatory,
                                   boolean editable,
                                   PropertyMetaModel<?> pmm)
This is the actual workhorse doing the per-builder actual placement and layouting of a {control, label} pair.

Parameters:
label -
labelnode -
list -
mandatory - T when the node is mandatory, needed by the label factory
editable - T when the node is editable, needed by the label factory
pmm -

addControl

protected abstract void addControl(NodeBase label,
                                   NodeBase labelnode,
                                   NodeBase[] list,
                                   boolean mandatory,
                                   boolean editable,
                                   PropertyMetaModel<?> pmm)

addContent

public abstract void addContent(NodeBase label,
                                NodeBase[] control,
                                boolean editable)

addListOfProperties

protected abstract IControl<?>[] addListOfProperties(boolean editable,
                                                     java.lang.String... names)
Handle placement of a list of property names, all obeying the current mode in effect.

Parameters:
editable -
names -

addProp

public IControl<?> addProp(java.lang.String name)
Add an input for the specified property. The property is based at the current input class. The input model is default (using metadata) and the property is labeled using the metadata-provided label. FORMAL-INTERFACE.

Parameters:
name -

addProp

public IControl<?> addProp(java.lang.String name,
                           java.lang.String label)
Add an input for the specified property. The property is based at the current input class. The input model is default (using metadata) and the property is labeled. FORMAL-INTERFACE.

Parameters:
name -
label - The label text to use. Use the empty string to prevent a label from being generated. This still adds an empty cell for the label though.

addProp

public IControl<?> addProp(java.lang.String name,
                           java.lang.String label,
                           boolean editable,
                           boolean mandatory)
Add an input for the specified property. The property is based at the current input class. The input model is default (using metadata) and the property is labeled using the metadata-provided label. FORMAL-INTERFACE.

Parameters:
name -
label - Add custom label.
editable - When false this adds a display-only field, when true a fully editable control.
mandatory - Specify if field is mandatory. This always overrides the mandatoryness of the metadata which is questionable.

addProp

public IControl<?> addProp(java.lang.String name,
                           boolean editable)
Add an input for the specified property. The property is based at the current input class. The input model is default (using metadata) and the property is labeled using the metadata-provided label. FORMAL-INTERFACE.

Parameters:
name -
editable - When false add a display-only control, else add an editable control.

addProp

public IControl<?> addProp(java.lang.String name,
                           boolean editable,
                           boolean mandatory)
Add an input for the specified property. The property is based at the current input class. The input model is default (using metadata) and the property is labeled using the metadata-provided label. FORMAL-INTERFACE.

Parameters:
name -
editable - When false this adds a display-only field, when true a fully editable control.
mandatory - Specify if field is mandatory. This always overrides the mandatoryness of the metadata which is questionable.

addContent

public void addContent(NodeBase label,
                       NodeBase control,
                       boolean editable)

addContent

public void addContent(java.lang.String label,
                       NodeBase control,
                       boolean editable)

addDisplayProp

public IControl<?> addDisplayProp(java.lang.String name)
Add a display-only field for the specified property. The field cannot be made editable.

Parameters:
name -

addDisplayProp

public IControl<?> addDisplayProp(java.lang.String name,
                                  java.lang.String label)
Add an input for the specified property just as addProp(String, String), only this input won't be editable (ever).

Parameters:
name -
label -

addProp

public <V,T extends NodeBase & IInputNode<V>> IControl<V> addProp(java.lang.String propertyname,
                                                                 T ctl)
Add a user-specified control for a given property. This adds the control, using the property-specified label and creates a binding for the property on the control. If you only want to add the proper structure and find the label for a property use addPropertyAndControl(String, NodeBase, boolean). FORMAL-INTERFACE.

Parameters:
propertyname -
ctl -

addDisplayProp

public <V,T extends NodeBase & IDisplayControl<V>> IControl<V> addDisplayProp(java.lang.String propertyname,
                                                                             T ctl)

addProp

public <V,T extends NodeBase & IInputNode<V>> IControl<V> addProp(java.lang.String name,
                                                                 java.lang.String label,
                                                                 T ctl)
Add a user-specified control for a given property. This adds the control, using the specified label and creates a binding for the property on the control. FORMAL-INTERFACE.

Parameters:
name -
label - The label text to use. Use the empty string to prevent a label from being generated. This still adds an empty cell for the label though.
ctl -

addLabelAndControl

public void addLabelAndControl(java.lang.String label,
                               NodeBase control,
                               boolean mandatory)
Add a fully manually specified label and control to the layout. This does not create any binding.

Parameters:
label -
control -
mandatory -

addLabelAndControl

public void addLabelAndControl(Label label,
                               java.lang.String errorLocation,
                               NodeBase control,
                               boolean mandatory)
Add a fully manually specified label and control to the layout. This does not create any binding. Since label caption can contain extra characters, error location can be assigned additionaly.

Parameters:
label -
errorLocation -
control -
mandatory -

addPropertyControl

protected IControl<?> addPropertyControl(java.lang.String name,
                                         java.lang.String label,
                                         PropertyMetaModel<?> pmm,
                                         boolean editable)
Parameters:
name -
label -
pmm -
editable - when false, the rendered control will be display-only.
Returns:
If the property was created and is controllable this will return an IFormControl instance. This will explicitly not be created if the control is display-only, not allowed by permissions or simply uncontrollable (the last one is uncommon).

addPropertyAndControl

public void addPropertyAndControl(java.lang.String propertyName,
                                  NodeBase nb,
                                  boolean mandatory)
This adds a fully user-specified control for a given property with it's default label, without creating any binding. The only reason the property is passed is to use it's metadata to define it's access rights and default label.

Parameters:
propertyName -
nb -
mandatory -

addProps

public IControl<?>[] addProps(java.lang.String... names)
Add the specified properties to the form, in the current mode. Watch out: if a MODIFIER is in place the modifier is obeyed for all properties, not for the first one only!! This means that when this gets called like:
        f.append().addProps("a", "b","c");
 
all three fields are appended to the current row. FORMAL-INTERFACE.

Parameters:
names -

addDisplayProps

public IControl<?>[] addDisplayProps(java.lang.String... names)
Add the specified properties to the form as display-only properties, in the current mode. Watch out: if a MODIFIER is in place the modifier is obeyed for all properties, not for the first one only!! This means that when this gets called like:
        f.append().addProps("a", "b","c");
 
all three fields are appended to the current row. FORMAL-INTERFACE.

Parameters:
names -