|
JavaGantt 2011.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteu.beesoft.gaia.app.Controller
eu.beesoft.gaia.app.FormController
public abstract class FormController
Abstract superclass for all form-based controllers. It supports data binding
- it extracts from given data objects data requested by the form, prepares it
for ApplicationResponse
and also processes returned changed data from
a client.
There are some methods you have to implement in your subclass:
getInstruction(Context)
- to get an instruction for client (such
as "display form", etc.)getFormId(Context)
- to get a form id (form name)getObject(Context)
- to get a processed data objectgetObjectsForListModel(String, Context)
- to get the data
objects for given list model
There is the method displayForm(Context)
which creates completed
application response with extracted and converted values from the context's
data object and with the data for list models. This method invokes all of
above methods.
The data extraction and data binding for displaying data on the client is
processed in method buildFormObject(Object, String, Context)
in
these steps:
FormDescriptor
instanceFormItem
instances to find the
binding
propertyValueObject
FormItem
If you want to use this built-in mechanism but you need to modify it, you can
override method getMiner()
to change the tool to access data
properties or
getPropertyValueFromDataObject(Object, String, Context)
to do the
same without changing the miner.
There is also the support to process the modified data from the client. It is
started with method acceptFormObject(ApplicationRequest, Context)
(you have to invoke it from your code yourself). It takes the server data
object (via getObject(Context)
method) and incoming data from the
client request, walks in client form object(s) property by property and
searches the appropriate property in data object(s). When it is found,
invokes method
acceptFormPropertyValue(Object, Object, Object, Object, String, Context)
to set changed value to the data object. Override this last method to:
acceptFormPropertyValue(Object, Object, Object, Object, String, Context)
.
Constructor Summary | |
---|---|
FormController()
|
Method Summary | |
---|---|
protected java.lang.Object |
acceptFormObject(ApplicationRequest request,
Context context)
Processes an object from AbstractRequestResponse.getData() to update
server data object with changes from client. |
protected java.lang.Object |
acceptFormPropertyValue(java.lang.Object formPropertyValue,
java.lang.Object formObject,
java.lang.Object dataPropertyValue,
java.lang.Object dataObject,
java.lang.String propertyName,
Context context)
Sets a new data property value to the given data object from the form property value and object. |
protected java.util.List<java.lang.Object> |
buildFormListModel(java.util.Collection<?> data,
java.lang.String listModelId,
java.lang.String formId,
Context context)
Returns the list of the objects for list model for the client, built from given data objects. |
protected java.lang.Object |
buildFormObject(java.lang.Object dataObject,
java.lang.String formId,
Context context)
Creates the object for the client form. |
protected void |
clearRegisteredDataObjects(Context context)
|
protected ApplicationResponse |
createResponse(java.lang.String instruction,
java.lang.String formId,
java.lang.Object object,
Context context)
Creates the response for client. |
protected ApplicationResponse |
displayForm(Context context)
Creates an application response Returns a root data object for this controller and given context. |
protected FormDescriptor |
getForm(java.lang.String formId)
Returns a form descriptor for given form id. |
protected abstract java.lang.String |
getFormId(Context context)
Returns a form id for this controller and given context. |
protected abstract java.lang.String |
getInstruction(Context context)
Returns an instruction for the newly constructed response. |
Miner |
getMiner()
Gets a miner of this controller. |
protected abstract java.lang.Object |
getObject(Context context)
Returns a root data object for this controller and given context. |
protected java.util.List<?> |
getObjectsForListModel(java.lang.String listModelId,
Context context)
Returns a list of data objects used to build the list model for the component with given id. |
protected java.lang.Object |
getPropertyValueFromDataObject(java.lang.Object dataObject,
java.lang.String propertyName,
Context context)
Returns a value of the requested property from the given object. |
protected java.lang.Object |
getRegisteredDataObject(java.lang.Long id,
Context context)
|
protected java.lang.Long |
getRegisteredDataObjectId(java.lang.Object object,
Context context)
|
protected ApplicationResponse |
process(ApplicationRequest request,
Context context)
Invokes a displayForm(Context) to build the response. |
protected void |
registerDataObject(java.lang.Object dataObject,
java.lang.Long id,
Context context)
|
void |
setMiner(Miner miner)
Sets a miner for this controller. |
protected void |
setPropertyValueToDataObject(java.lang.Object dataObject,
java.lang.String propertyName,
java.lang.Object propertyValue,
Context context)
Sets a given value to the requested property of the given object. |
Methods inherited from class eu.beesoft.gaia.app.Controller |
---|
addMapping, createContextForForward, failure, forward, getController, getMapping, returnFailure, returnSuccess, setMapping, success |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FormController()
Method Detail |
---|
protected FormDescriptor getForm(java.lang.String formId)
formId
- - form id (name of the form file)
java.lang.RuntimeException
- if form cannot be found or loadedprotected ApplicationResponse process(ApplicationRequest request, Context context)
displayForm(Context)
to build the response.
process
in class Controller
request
- - client request to processcontext
- - current context
protected abstract java.lang.String getInstruction(Context context)
context
- - current context
protected abstract java.lang.String getFormId(Context context)
context
- - current context
protected abstract java.lang.Object getObject(Context context)
context
- - current context
protected ApplicationResponse displayForm(Context context)
getInstruction(Context)
getFormId(Context)
getObject(Context)
createResponse(String, String, Object, Context)
context
- - current context
protected ApplicationResponse createResponse(java.lang.String instruction, java.lang.String formId, java.lang.Object object, Context context)
buildFormObject(Object, String, Context)
method to extract data
for form from given object
. Then for each list model invokes
getObjectsForListModel(String, Context)
to get list model data.
The created and initialized application response is returned.
instruction
- - an instruction name (fot the client)formId
- - form id (name of the form XML file)object
- - data object to display on clientcontext
- - current context
protected java.util.List<?> getObjectsForListModel(java.lang.String listModelId, Context context)
listModelId
- - the id of list model componentcontext
- - the current context
public Miner getMiner()
public void setMiner(Miner miner)
miner
- the miner to setprotected void registerDataObject(java.lang.Object dataObject, java.lang.Long id, Context context)
protected java.lang.Object getRegisteredDataObject(java.lang.Long id, Context context)
protected java.lang.Long getRegisteredDataObjectId(java.lang.Object object, Context context)
protected void clearRegisteredDataObjects(Context context)
protected java.lang.Object buildFormObject(java.lang.Object dataObject, java.lang.String formId, Context context)
formId
and then searches each form item for
binding
and item binding
properties. It gets a
requested property from given data object for each found binding. This
process is performed on referenced data objects, too, so it extracts and
converts all needed data to display on the client in given form.
dataObject
- - root data object for data extractionformId
- - the form idcontext
- - the current context
protected java.util.List<java.lang.Object> buildFormListModel(java.util.Collection<?> data, java.lang.String listModelId, java.lang.String formId, Context context)
data
objects.
data
- - the collection of data objects for list modellistModelId
- - the id of list model (from the form XML file)formId
- - the form idcontext
- - the current context
protected java.lang.Object getPropertyValueFromDataObject(java.lang.Object dataObject, java.lang.String propertyName, Context context)
Miner
. The miner tries to get a property via the getter, the
field access and via getProperty() method for ValueObject
instance (in this order). Override it if you need some special access to
the requested property.
dataObject
- - the object from which is property requestedpropertyName
- - the name of the requested propertycontext
- - the current context
protected java.lang.Object acceptFormObject(ApplicationRequest request, Context context)
AbstractRequestResponse.getData()
to update
server data object with changes from client. Returns an updated server
data object.
request
- - the client request to processcontext
- - the current context
protected void setPropertyValueToDataObject(java.lang.Object dataObject, java.lang.String propertyName, java.lang.Object propertyValue, Context context)
Miner.setValue(Object, String, Object)
. The miner tries to set a
property via the setter, the field access and via setProperty() method
for ValueObject
instance (in this order). Override it if you need
some special access to set the property.
dataObject
- - the owner of the propertypropertyName
- - the name of the requested propertypropertyValue
- - the value to set to the propertycontext
- - the current contextprotected java.lang.Object acceptFormPropertyValue(java.lang.Object formPropertyValue, java.lang.Object formObject, java.lang.Object dataPropertyValue, java.lang.Object dataObject, java.lang.String propertyName, Context context)
This method is invoked from
acceptFormObject(ApplicationRequest, Context)
method.
formPropertyValue
- - value from the form object at given propertyNameformObject
- - the form object - container for formPropertyValuedataPropertyValue
- - value from the data object at given propertyNamedataObject
- - the data object - container for dataPropertyValuepropertyName
- - the name of the property which is processedcontext
- - the current context
|
JavaGantt 2011.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |