public abstract class OwFieldManager extends OwEventTarget
Base Class for field User Interface.
Displays field as HTML and creates HTML Form Elements for editing properties,
also performs Validation.
You get a instance of the FieldManager by calling getContext().createFieldManager().
Use this instance with all fields in your view.
To be implemented with the specific DMS system.
Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.
For licensing information read the license.txt file or
go to: http://wiki.alfresco.com
Modifier and Type | Field and Description |
---|---|
static String |
FLAG_DISABLE_VALIDATION
Parameter to disable validation handling of values.
|
protected OwEventTarget |
m_externalFormEventTarget
external form view overrides internal form
|
protected Map |
m_FieldErrors
list of strings, which designate errors on fields
|
protected Map |
m_ids2displayNames
map between fields display names and their render Id, used for better error reporting
|
protected OwMainAppContext |
m_MainContext
reference to the cast AppContext
|
protected Map |
m_ObjectMap
map which keeps the objects to be edited / displayed and create links upon
|
Constructor and Description |
---|
OwFieldManager() |
Modifier and Type | Method and Description |
---|---|
abstract void |
attachFieldControlByClass(String strFieldClassName_p,
OwFieldManagerControl control_p,
Node configNode_p)
attach a field control to the field manager
|
abstract void |
attachFieldControlByType(String strJavaClassName_p,
OwFieldManagerControl control_p,
Node configNode_p)
attach a field control to the field manager
|
void |
clearFieldError(OwField field_p)
Clears the errors associated with the given field.
If no errors remain the m_FieldErrors map is set to null |
static void |
computeChangedFields(Map originalFields_p,
Map compareFields_p,
Map changedProperties_p)
compare to field maps and return the changed fields
|
abstract Object |
convertValue(javax.servlet.http.HttpServletRequest request_p,
OwFieldDefinition fieldDef_p,
Object value_p,
String strID_p)
Will extract the value from request, and transform it into dependent type representation defined by OwFieldDefinition.
|
protected OwXMLUtil |
getConfigNode()
Get configuration node for current manager instance.
|
OwField |
getField(String strID_p)
get the Field from the given ID
|
String |
getFieldJSErrorCtrlID(OwField field_p)
get the ID that should be used for the HTML element to display JavaScript errors
keep the ID in sync, so that JS Errors can be displayed as well.
|
OwFieldProvider |
getFieldProvider()
get an interface to a field provider interface
the field provider interface can be used by the fields to reference other fields.
|
String |
getFocusControlID()
retrieve the control ID of the control that should receive the input focus, usually the first field
|
String |
getFormName()
get the form used for the template edit fields
Returns the internal render form or the external one
if you called setFormName.
|
OwEventTarget |
getFormTarget()
get the target, that is used for form date and renders form
|
abstract OwMimeManager |
getMimeManager()
get a reference to a MIME manager that can be used to render objects
|
String |
getSafeFieldError(OwField field_p)
writes a error message for the requested field, if the field contained an invalid value after user edited it.
|
boolean |
getUpdateStatus()
get the status after the last update
|
protected void |
init()
init the target after the context is set.
|
void |
init(OwXMLUtil configNode_p)
init the field manager upon creation
|
void |
insertEditField(Writer w_p,
OwField field_p)
Format and displays the value attached to the fieldClass in HTML for use in a HTML Form.
|
protected abstract void |
insertEditFieldInternal(Writer w_p,
OwFieldDefinition fieldDef_p,
OwField field_p,
String strID_p)
Format and displays the value attached to the fieldClass in HTML for use in a HTML form.
|
abstract void |
insertLabel(Writer w_p,
boolean readOnlyView_p,
boolean readOnly_p,
OwField field_p,
String suffix_p,
boolean writeLabel_p)
Renders a property control label on the given Writer
|
void |
insertReadOnlyField(Writer w_p,
OwField field_p)
Format and displays the value attached to the fieldClass in HTML
|
protected abstract void |
insertReadOnlyFieldInternal(Writer w_p,
OwFieldDefinition fieldDef_p,
Object value_p)
Format and displays the value attached to the fieldClass in HTML
|
boolean |
isFieldProviderName(String sName_p)
check if has given name
|
boolean |
isFieldProviderType(int iFieldProviderType_p)
check if has given type
|
String |
renderErrors()
Render all errors collected by this
OwFieldManager object |
void |
reset()
clear the map before you call insert...
|
void |
resetErrors()
Clear the error maps
|
protected static boolean |
safeEqual(Object obj1_p,
Object obj2_p)
check if both values equal, works on null pointers as well
|
void |
setExternalFormTarget(OwEventTarget eventtarget_p)
override the internal OwEditable with an external one,
must be called BEFORE view is attached.
|
void |
setFieldError(OwField field_p,
String strError_p)
Sets the given error message for the given field.
|
void |
setFieldProvider(OwFieldProvider fieldProvider_p)
set reference to a field provider interface
the field provider interface can be used by the fields to reference other fields. |
protected void |
setFocusControlID(String strFocusControlID_p) |
boolean |
update(javax.servlet.http.HttpServletRequest request_p,
Map changedFields_p,
Map compareMap_p)
update the field values upon request and validates the new values.
|
protected boolean |
update(javax.servlet.http.HttpServletRequest request_p,
Map changedFields_p,
Map compareMap_p,
boolean fIgnoreErrors_p)
update the field values upon request and validates the new values.
|
boolean |
updateExternalFormTarget(javax.servlet.http.HttpServletRequest request_p,
boolean fSave_p)
update the view after a view event (caused by getEditableViewEventURL), so it can set its form fields
|
protected abstract Object |
updateFieldInternal(javax.servlet.http.HttpServletRequest request_p,
OwFieldDefinition fieldDef_p,
Object value_p,
String strID_p)
update the property value upon request and validates the new value.
|
attach, detach, disableRequestListener, enableRequestListener, getAjaxEventURL, getContext, getEventURL, getFormEventFunction, getFormEventURL, getID, onExternalRequest, onFormEvent, onRequest
public static final String FLAG_DISABLE_VALIDATION
protected OwMainAppContext m_MainContext
protected Map m_ObjectMap
protected Map m_FieldErrors
protected Map m_ids2displayNames
protected OwEventTarget m_externalFormEventTarget
protected OwXMLUtil getConfigNode()
protected void init() throws Exception
OwEventTarget
init
in class OwEventTarget
Exception
public void init(OwXMLUtil configNode_p) throws Exception
configNode_p
- OwXMLUtil node with configuration informationException
public OwField getField(String strID_p)
strID_p
- String IDpublic void setFieldProvider(OwFieldProvider fieldProvider_p)
fieldProvider_p
- OwFieldProvider interfacepublic boolean isFieldProviderType(int iFieldProviderType_p)
iFieldProviderType_p
- int type to querypublic boolean isFieldProviderName(String sName_p)
sName_p
- String name to querypublic OwFieldProvider getFieldProvider()
public OwEventTarget getFormTarget()
getFormTarget
in class OwEventTarget
public void insertReadOnlyField(Writer w_p, OwField field_p) throws Exception
w_p
- Writer object to write HTML tofield_p
- OwField Value to be displayedException
protected abstract void insertReadOnlyFieldInternal(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p) throws Exception
w_p
- Writer object to write HTML tofieldDef_p
- OwFieldDefinition definition of fieldvalue_p
- Object Value to be displayedException
public String getFocusControlID()
protected void setFocusControlID(String strFocusControlID_p)
strFocusControlID_p
- the m_strFocusControlID to setpublic void insertEditField(Writer w_p, OwField field_p) throws Exception
w_p
- Writer object to write HTML tofield_p
- OwField Value to be displayedException
protected abstract void insertEditFieldInternal(Writer w_p, OwFieldDefinition fieldDef_p, OwField field_p, String strID_p) throws Exception
w_p
- Writer object to write HTML tofieldDef_p
- OwFieldDefinition definition of fieldfield_p
- OwField Value to be displayedstrID_p
- ID of the HTML elementException
protected static boolean safeEqual(Object obj1_p, Object obj2_p)
obj1_p
- first object to compare, can be nullobj2_p
- second object to compare, can be nullpublic static void computeChangedFields(Map originalFields_p, Map compareFields_p, Map changedProperties_p) throws Exception
originalFields_p
- the original fields to comparecompareFields_p
- the compare mapchangedProperties_p
- Map of returned changed fieldsException
public boolean update(javax.servlet.http.HttpServletRequest request_p, Map changedFields_p, Map compareMap_p) throws Exception
request_p
- HttpServletRequestchangedFields_p
- optional return map of changed fields, can be null. If compareMap_p is null, compares to the previous valuecompareMap_p
- optional map with original map to compare to, can be nullException
protected boolean update(javax.servlet.http.HttpServletRequest request_p, Map changedFields_p, Map compareMap_p, boolean fIgnoreErrors_p) throws Exception
request_p
- HttpServletRequestchangedFields_p
- optional return map of changed fields, can be null. If compareMap_p is null, compares to the previous valuecompareMap_p
- optional map with original map to compare to, can be nullfIgnoreErrors_p
- boolean disable error collection for pure updatesException
public String getFieldJSErrorCtrlID(OwField field_p)
field_p
- String
public String getSafeFieldError(OwField field_p) throws Exception
field_p
- the requested fieldException
public void resetErrors()
public String renderErrors() throws Exception
OwFieldManager
objectpublic void clearFieldError(OwField field_p)
m_FieldErrors
map is set to null
field_p
- public void setFieldError(OwField field_p, String strError_p)
field_p
- strError_p
- public boolean getUpdateStatus()
protected abstract Object updateFieldInternal(javax.servlet.http.HttpServletRequest request_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p) throws Exception
request_p
- HttpServletRequestfieldDef_p
- OwFieldDefinition definition of fieldvalue_p
- Object old ValuestrID_p
- ID of the HTML elementException
public abstract void attachFieldControlByClass(String strFieldClassName_p, OwFieldManagerControl control_p, Node configNode_p) throws Exception
strFieldClassName_p
- class name of the field that uses the controlcontrol_p
- OwFieldManagerControl that renders the fieldconfigNode_p
- DOM Node to the configuration XML for the control, or null to use defaultsException
public abstract void attachFieldControlByType(String strJavaClassName_p, OwFieldManagerControl control_p, Node configNode_p) throws Exception
strJavaClassName_p
- java type of the field that uses the controlcontrol_p
- OwFieldManagerControl that renders the fieldconfigNode_p
- DOM Node to the configuration XML for the control, or null to use defaultsException
public abstract OwMimeManager getMimeManager()
public void reset()
NOTE: Never forget to call this function in your onRender Method
public boolean updateExternalFormTarget(javax.servlet.http.HttpServletRequest request_p, boolean fSave_p) throws Exception
updateExternalFormTarget
in class OwEventTarget
request_p
- HttpServletRequestfSave_p
- boolean true = save the changes of the form data, false = just update the form data, but do not saveException
public void setExternalFormTarget(OwEventTarget eventtarget_p) throws Exception
setExternalFormTarget
in class OwEventTarget
eventtarget_p
- OwEventTargetException
public String getFormName()
getFormName
in class OwEventTarget
public abstract void insertLabel(Writer w_p, boolean readOnlyView_p, boolean readOnly_p, OwField field_p, String suffix_p, boolean writeLabel_p) throws Exception
w_p
- WriterreadOnlyView_p
- Read only view flagreadOnly_p
- Read only property flagfield_p
- Property to be renderedsuffix_p
- StringwriteLabel_p
- boolean Write LabelException
public abstract Object convertValue(javax.servlet.http.HttpServletRequest request_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p) throws OwException
request_p
- HttpServletRequestfieldDef_p
- OwFieldDefinitionvalue_p
- Object old/current value of fieldstrID_p
- String id of fieldOwException
- if unable to convert valueCopyright © 2014 Alfresco Business Solutions. All Rights Reserved.