BDO
- public abstract class DataObjectFormFactory<BDO extends DataObject> extends java.lang.Object implements FormFactory, IndexedProducer<BDO>
The class implements IndexedProducer
by forwarding onto the nested factory. This allows custom from factories to be installed in
IndexedFormEntry
s to produce specialised creation forms that add entries to an existing factory.
Note that if FieldConstraint
s are defined form building may return early (returning false from the buildForm methods)
indicating that multi-stage forms are being used.
The customise methods are usually still called so these (or any validators they add) may need to be tolerant about missing fields
when using FieldConstraints
Modifier and Type | Field and Description |
---|---|
static Feature |
DEFAULT_FORBID_HTML |
protected DataObjectFactory<BDO> |
factory |
Modifier | Constructor and Description |
---|---|
protected |
DataObjectFormFactory(DataObjectFactory<BDO> fac) |
Modifier and Type | Method and Description |
---|---|
protected java.util.Set<java.lang.String> |
addOptionalFromComposites(java.util.Set<java.lang.String> optional) |
static java.util.Map<java.lang.String,Selector> |
addSelectors(AppContext conn,
java.util.Map<java.lang.String,Selector> sel,
Repository res)
Add a set of selectors based on the tables referenced by field keys
|
static java.util.Map<java.lang.String,java.lang.String> |
addTranslations(AppContext conn,
java.util.Map<java.lang.String,java.lang.String> trans,
Repository res)
Add default translations for reference fields using the table name in
preference to the field name.
|
static boolean |
buildForm(AppContext conn,
Repository res,
Form f,
java.util.Set<java.lang.String> supress_fields,
java.util.Set<java.lang.String> optional,
java.util.Map<java.lang.String,Selector> selectors,
java.util.Map<java.lang.String,java.lang.String> labels) |
static boolean |
buildForm(AppContext conn,
Repository res,
Form f,
java.util.Set<java.lang.String> supress_fields,
java.util.Set<java.lang.String> optional,
java.util.Map<java.lang.String,Selector> selectors,
java.util.Map<java.lang.String,java.lang.String> labels,
java.util.Map<java.lang.String,java.lang.String> tooltips)
Construct an edit Form for the associated DataObject based on database
meta-data
|
static boolean |
buildForm(AppContext conn,
Repository res,
java.util.Set<java.lang.String> keys,
Form f,
java.util.Set<java.lang.String> optional,
java.util.Map<java.lang.String,Selector> selectors,
java.util.Map<java.lang.String,FieldConstraint> constraints,
java.util.Map<java.lang.String,java.lang.String> labels,
java.util.Map<java.lang.String,java.lang.String> tooltips,
java.util.HashMap fixtures)
Construct an edit Form for the associated DataObject based on database
meta-data
|
boolean |
buildForm(Form f)
builds a default Form for editing the DataObjects belonging to this
DataObjectFactory The state of the Form is initialised using getDefaults
|
boolean |
buildForm(Form f,
java.util.HashMap fixtures) |
void |
customiseForm(Form f)
Extension hook to allow additional Form customisation generic to all
types of Form For example adding a FormValidator or adding min, max
values to NumberInputs.
|
BDO |
find(int id) |
BDO |
find(java.lang.Number o)
Find the required object.
|
AppContext |
getContext() |
java.util.Map<java.lang.String,java.lang.Object> |
getDefaults()
Get a set of default values for the form fields
|
DataObjectFactory<BDO> |
getFactory() |
protected java.util.Map<java.lang.String,FieldConstraint> |
getFieldConstraints()
get
FieldConstraint s to apply when building the form |
protected java.util.Map<java.lang.String,java.lang.String> |
getFieldHelp()
create additional tooltip help text for form fields.
|
protected java.util.Set<java.lang.String> |
getFields() |
java.lang.String |
getID(BDO obj)
Generate the default text identifier of the client object for contexts where
the type is unambiguous.
|
java.lang.Number |
getIndex(BDO value)
Get the underlying data representation corresponding to the value
|
static Input<?> |
getInputFromName(AppContext conn,
java.lang.String table,
java.lang.String name) |
static Input<?> |
getInputFromType(AppContext conn,
Repository res,
Repository.FieldInfo info) |
protected Logger |
getLogger() |
protected java.util.Set<java.lang.String> |
getOptional()
Generate the set of optional fields to be used in form creation/update
default behaviour is to take the set defined by the factory
(or if this is null fields that can be null in the database) modified by
the
Composite classes. |
protected java.util.Map<java.lang.String,Selector> |
getSelectors()
Get a Map of selectors to use for forms of this type.
|
protected java.util.Set<java.lang.String> |
getSupress()
generate the set of suppressed fields to be used in form creation/update
|
java.lang.Class<BDO> |
getTarget()
Get a class object that all results of the producer are assignable to.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getTranslations()
return a default set of translation between field names and text labels.
|
boolean |
isMyReference(IndexedReference ref)
Test if an IndexedReference belongs to this producer.
|
IndexedReference<BDO> |
makeReference(BDO obj)
Make a IndexedReference from a target object
|
IndexedReference<BDO> |
makeReference(int id)
Make and IndexedReferencce from an integer id.
|
public static final Feature DEFAULT_FORBID_HTML
protected final DataObjectFactory<BDO extends DataObject> factory
protected DataObjectFormFactory(DataObjectFactory<BDO> fac)
public final AppContext getContext()
getContext
in interface FormFactory
public final DataObjectFactory<BDO> getFactory()
protected final Logger getLogger()
public final boolean buildForm(Form f) throws DataFault
f
- Form to buildDataFault
TransitionException
public final boolean buildForm(Form f, java.util.HashMap fixtures) throws DataFault
DataFault
public static final boolean buildForm(AppContext conn, Repository res, Form f, java.util.Set<java.lang.String> supress_fields, java.util.Set<java.lang.String> optional, java.util.Map<java.lang.String,Selector> selectors, java.util.Map<java.lang.String,java.lang.String> labels) throws DataFault
DataFault
public static final boolean buildForm(AppContext conn, Repository res, Form f, java.util.Set<java.lang.String> supress_fields, java.util.Set<java.lang.String> optional, java.util.Map<java.lang.String,Selector> selectors, java.util.Map<java.lang.String,java.lang.String> labels, java.util.Map<java.lang.String,java.lang.String> tooltips) throws DataFault
conn
- AppContextres
- Repository to use as templatef
- Form to buildsupress_fields
- Vector of fields to supress in the formoptional
- Vector marking fields as optionalselectors
- Map of selectors to use.labels
- Map of field names to form labelsDataFault
TransitionException
public static final boolean buildForm(AppContext conn, Repository res, java.util.Set<java.lang.String> keys, Form f, java.util.Set<java.lang.String> optional, java.util.Map<java.lang.String,Selector> selectors, java.util.Map<java.lang.String,FieldConstraint> constraints, java.util.Map<java.lang.String,java.lang.String> labels, java.util.Map<java.lang.String,java.lang.String> tooltips, java.util.HashMap fixtures) throws DataFault
conn
- AppContextres
- Repository to use as templatef
- Form to buildsupress_fields
- Vector of fields to supress in the formoptional
- Vector marking fields as optionalselectors
- Map of selectors to use.labels
- Map of field names to form labelstooltips
- Map of tooltip/help text for form labelsDataFault
TransitionException
public static Input<?> getInputFromType(AppContext conn, Repository res, Repository.FieldInfo info)
public static Input<?> getInputFromName(AppContext conn, java.lang.String table, java.lang.String name)
public static java.util.Map<java.lang.String,Selector> addSelectors(AppContext conn, java.util.Map<java.lang.String,Selector> sel, Repository res)
conn
- sel
- res
- public static java.util.Map<java.lang.String,java.lang.String> addTranslations(AppContext conn, java.util.Map<java.lang.String,java.lang.String> trans, Repository res)
conn
- trans
- res
- public void customiseForm(Form f)
f
- Form
to modifyprotected java.util.Map<java.lang.String,Selector> getSelectors()
protected java.util.Set<java.lang.String> getSupress()
protected java.util.Set<java.lang.String> getFields()
protected java.util.Map<java.lang.String,java.lang.String> getTranslations()
protected java.util.Map<java.lang.String,java.lang.String> getFieldHelp()
protected java.util.Set<java.lang.String> getOptional()
Composite
classes.
most classes will override with an explicit list of optional fields.
If this method is overridden to return an empty set no fields are optional.
If it is overridden to return null then fields tha can take null values are optional.Set
of field namesprotected java.util.Set<java.lang.String> addOptionalFromComposites(java.util.Set<java.lang.String> optional)
optional
- public java.util.Map<java.lang.String,java.lang.Object> getDefaults()
protected java.util.Map<java.lang.String,FieldConstraint> getFieldConstraints()
FieldConstraint
s to apply when building the formpublic final BDO find(int id) throws DataException
find
in interface IndexedProducer<BDO extends DataObject>
DataException
public final java.lang.Class<BDO> getTarget()
IndexedProducer
getTarget
in interface IndexedProducer<BDO extends DataObject>
getTarget
in interface Targetted<BDO extends DataObject>
public final IndexedReference<BDO> makeReference(BDO obj)
IndexedProducer
makeReference
in interface IndexedProducer<BDO extends DataObject>
public final IndexedReference<BDO> makeReference(int id)
IndexedProducer
makeReference
in interface IndexedProducer<BDO extends DataObject>
public final boolean isMyReference(IndexedReference ref)
IndexedProducer
isMyReference
in interface IndexedProducer<BDO extends DataObject>
public final java.lang.String getID(BDO obj)
IndexedProducer
IndexedProducer
should
implement ParseFactory
to be able to parse the alternative form.getID
in interface IndexedProducer<BDO extends DataObject>
public final BDO find(java.lang.Number o)
TypeConverter
find
in interface TypeConverter<BDO extends DataObject,java.lang.Number>
o
- Value of the database fieldpublic final java.lang.Number getIndex(BDO value)
TypeConverter
getIndex
in interface TypeConverter<BDO extends DataObject,java.lang.Number>