to.etc.domui.component.form
Class FormBuilderBase

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

public class FormBuilderBase
extends java.lang.Object

Base class for form builder engines.

Author:
Frits Jalvingh Created on Aug 13, 2009

Field Summary
protected static org.slf4j.Logger LOG
           
 
Constructor Summary
FormBuilderBase()
           
FormBuilderBase(java.lang.Class<T> clz, IReadOnlyModel<T> mdl)
          Constructor to immediately initialize for a given class and reader.
FormBuilderBase(T instance)
          Initialize with a single unchangeable instance.
 
Method Summary
protected  ControlFactoryResult createControlFor(IReadOnlyModel<?> model, PropertyMetaModel<?> pmm, boolean editable)
           
protected  ControlFactoryResult createControlFor(IReadOnlyModel<?> model, PropertyMetaModel<?> pmm, boolean editable, java.lang.Object context)
          Create the optimal control for the specified thingy, and return the binding for it.
 ModelBindings getBindings()
           
 ControlBuilder getBuilder()
           
protected  ClassMetaModel getClassMeta()
          Return the currently active class metamodel (the model that properties are obtained from).
 java.lang.Object getContext()
           
 IControlLabelFactory getControlLabelFactory()
          Return the factory to use for creating control labels from metadata.
 java.lang.Class<?> getCurrentInputClass()
           
 IReadOnlyModel<?> getModel()
          Return the current ReadOnlyModel which is the accessor to get the instance that will be edited.
protected  PropertyMetaModel<?> resolveProperty(java.lang.String name)
          Find a property relative to the current input class.
protected  AccessCalculator rights()
          Access the shared permissions calculator.
 void setBindings(ModelBindings bindings)
           
<T> void
setClassModel(java.lang.Class<T> clz, IReadOnlyModel<T> mdl)
          Set or change the current base class and base model.
 void setContext(java.lang.Object context)
           
 void setControlLabelFactory(IControlLabelFactory controlLabelFactory)
           
<T> void
setInstance(T instance)
           
 void setMetaModel(ClassMetaModel cmm, IReadOnlyModel<?> source)
          Sets the base metamodel and value source to use for obtaining properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.slf4j.Logger LOG
Constructor Detail

FormBuilderBase

public FormBuilderBase()

FormBuilderBase

public FormBuilderBase(java.lang.Class<T> clz,
                       IReadOnlyModel<T> mdl)
Constructor to immediately initialize for a given class and reader.

Type Parameters:
T -
Parameters:
clz -
mdl -

FormBuilderBase

public FormBuilderBase(T instance)
Initialize with a single unchangeable instance. Please consider using a model though as it is more resilient to changes.

Type Parameters:
T -
Parameters:
instance -
Method Detail

getBuilder

public final ControlBuilder getBuilder()

createControlFor

protected ControlFactoryResult createControlFor(IReadOnlyModel<?> model,
                                                PropertyMetaModel<?> pmm,
                                                boolean editable,
                                                java.lang.Object context)
Create the optimal control for the specified thingy, and return the binding for it.

Parameters:
container - This will receive all nodes forming the control.
model - The content model used to obtain the Object instance whose property is being edited, for binding purposes.
pmm - The property meta for the property to find an editor for.
editable - When false this must make a displayonly control.
Returns:
The binding to bind the control to it's valueset

createControlFor

protected ControlFactoryResult createControlFor(IReadOnlyModel<?> model,
                                                PropertyMetaModel<?> pmm,
                                                boolean editable)

rights

protected AccessCalculator rights()
Access the shared permissions calculator.


getContext

public java.lang.Object getContext()

setContext

public void setContext(java.lang.Object context)

setClassModel

public <T> void setClassModel(java.lang.Class<T> clz,
                              IReadOnlyModel<T> mdl)
Set or change the current base class and base model. This can be changed whenever needed.

Type Parameters:
T -
Parameters:
clz -
mdl -

setMetaModel

public void setMetaModel(ClassMetaModel cmm,
                         IReadOnlyModel<?> source)
Sets the base metamodel and value source to use for obtaining properties.

Parameters:
cmm -
source -

setInstance

public <T> void setInstance(T instance)

getClassMeta

protected ClassMetaModel getClassMeta()
Return the currently active class metamodel (the model that properties are obtained from). This will never return null.

Returns:

resolveProperty

protected PropertyMetaModel<?> resolveProperty(java.lang.String name)
Find a property relative to the current input class.

Parameters:
name -
Returns:

getModel

public IReadOnlyModel<?> getModel()
Return the current ReadOnlyModel which is the accessor to get the instance that will be edited. This will never return null.

Returns:

getCurrentInputClass

public java.lang.Class<?> getCurrentInputClass()

getBindings

public ModelBindings getBindings()

setBindings

public void setBindings(ModelBindings bindings)

getControlLabelFactory

public IControlLabelFactory getControlLabelFactory()
Return the factory to use for creating control labels from metadata.

Returns:

setControlLabelFactory

public void setControlLabelFactory(IControlLabelFactory controlLabelFactory)