com.wewebu.ow.server.app
Class OwFieldManager

java.lang.Object
  extended by com.wewebu.ow.server.ui.OwEventTarget
      extended by com.wewebu.ow.server.app.OwFieldManager
Direct Known Subclasses:
OwStandardFieldManager

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


Field Summary
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 they hashcode, 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 Summary
OwFieldManager()
           
 
Method Summary
abstract  void attachFieldControlByClass(String strFieldClassName_p, OwFieldManagerControl control_p, Node configNode_p)
          attach a field control to the fieldmanager
abstract  void attachFieldControlByType(String strJavaClassName_p, OwFieldManagerControl control_p, Node configNode_p)
          attach a field control to the fieldmanager
 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
protected  OwXMLUtil getConfigNode()
          get configuration node with XML config information
 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, OwProperty property_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 an interface 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.
 
Methods inherited from class com.wewebu.ow.server.ui.OwEventTarget
attach, detach, disableRequestListener, enableRequestListener, getAjaxEventURL, getContext, getEventURL, getFormEventFunction, getFormEventURL, getID, onExternalRequest, onFormEvent, onRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_MainContext

protected OwMainAppContext m_MainContext
reference to the cast AppContext


m_ObjectMap

protected Map m_ObjectMap
map which keeps the objects to be edited / displayed and create links upon


m_FieldErrors

protected Map m_FieldErrors
list of strings, which designate errors on fields


m_ids2displayNames

protected Map m_ids2displayNames
map between fields display names and they hashcode, used for better error reporting


m_externalFormEventTarget

protected OwEventTarget m_externalFormEventTarget
external form view overrides internal form

Constructor Detail

OwFieldManager

public OwFieldManager()
Method Detail

getConfigNode

protected OwXMLUtil getConfigNode()
get configuration node with XML config information


init

protected void init()
             throws Exception
init the target after the context is set.

Specified by:
init in class OwEventTarget
Throws:
Exception

init

public void init(OwXMLUtil configNode_p)
          throws Exception
init the field manager upon creation

Parameters:
configNode_p - OwXMLUtil node with configuration information
Throws:
Exception

getField

public OwField getField(String strID_p)
get the Field from the given ID

Parameters:
strID_p - String ID
Returns:
OwField

setFieldProvider

public void setFieldProvider(OwFieldProvider fieldProvider_p)
set an interface to a field provider interface the field provider interface can be used by the fields to reference other fields. setting the field provider is optional

Parameters:
fieldProvider_p - OwFieldProvider interface

isFieldProviderType

public boolean isFieldProviderType(int iFieldProviderType_p)
check if has given type

Parameters:
iFieldProviderType_p - int typeflag to query
Returns:
boolean true if fieldprovider is of given type

isFieldProviderName

public boolean isFieldProviderName(String sName_p)
check if has given name

Parameters:
sName_p - String name to query
Returns:
boolean true if fieldprovider is of given type

getFieldProvider

public OwFieldProvider getFieldProvider()
get an interface to a field provider interface the field provider interface can be used by the fields to reference other fields.

Returns:
OwFieldProvider or null if no field provider is available

getFormTarget

public OwEventTarget getFormTarget()
get the target, that is used for form date and renders form

Overrides:
getFormTarget in class OwEventTarget
Returns:
OwEventTarget

insertReadOnlyField

public void insertReadOnlyField(Writer w_p,
                                OwField field_p)
                         throws Exception
Format and displays the value attached to the fieldClass in HTML

Parameters:
w_p - Writer object to write HTML to
field_p - OwField Value to be displayed
Throws:
Exception

insertReadOnlyFieldInternal

protected abstract void insertReadOnlyFieldInternal(Writer w_p,
                                                    OwFieldDefinition fieldDef_p,
                                                    Object value_p)
                                             throws Exception
Format and displays the value attached to the fieldClass in HTML

Parameters:
w_p - Writer object to write HTML to
fieldDef_p - OwFieldDefinition definition of field
value_p - Object Value to be displayed
Throws:
Exception

getFocusControlID

public String getFocusControlID()
retrieve the control ID of the control that should receive the input focus, usually the first field


setFocusControlID

protected void setFocusControlID(String strFocusControlID_p)
Parameters:
strFocusControlID_p - the m_strFocusControlID to set
Since:
3.1.0.4

insertEditField

public void insertEditField(Writer w_p,
                            OwField field_p)
                     throws Exception
Format and displays the value attached to the fieldClass in HTML for use in a HTML Form. It also creates the necessary code to update the value in the form upon request.

Parameters:
w_p - Writer object to write HTML to
field_p - OwField Value to be displayed
Throws:
Exception

insertEditFieldInternal

protected abstract void insertEditFieldInternal(Writer w_p,
                                                OwFieldDefinition fieldDef_p,
                                                OwField field_p,
                                                String strID_p)
                                         throws Exception
Format and displays the value attached to the fieldClass in HTML for use in a HTML form. It also creates the necessary code to update the value in the form upon request.

Parameters:
w_p - Writer object to write HTML to
fieldDef_p - OwFieldDefinition definition of field
field_p - OwField Value to be displayed
strID_p - ID of the HTML element
Throws:
Exception

safeEqual

protected static boolean safeEqual(Object obj1_p,
                                   Object obj2_p)
check if both values equal, works on null pointers as well

Parameters:
obj1_p - first object to compare, can be null
obj2_p - second object to compare, can be null
Returns:
true if both values match or both are null, false otherwise

computeChangedFields

public static void computeChangedFields(Map originalFields_p,
                                        Map compareFields_p,
                                        Map changedProperties_p)
                                 throws Exception
compare to field maps and return the changed fields

Parameters:
originalFields_p - the original fields to compare
compareFields_p - the compare map
changedProperties_p - Map of returned changed fields
Throws:
Exception

update

public boolean update(javax.servlet.http.HttpServletRequest request_p,
                      Map changedFields_p,
                      Map compareMap_p)
               throws Exception
update the field values upon request and validates the new values. displays error message if fields could not be updated

Parameters:
request_p - HttpServletRequest
changedFields_p - optional return map of changed fields, can be null. If compareMap_p is null, compares to the previous value
compareMap_p - optional map with original map to compare to, can be null
Returns:
true = all fields are valid, false = one or more fields are invalid
Throws:
Exception

update

protected boolean update(javax.servlet.http.HttpServletRequest request_p,
                         Map changedFields_p,
                         Map compareMap_p,
                         boolean fIgnoreErrors_p)
                  throws Exception
update the field values upon request and validates the new values. displays error message if fields could not be updated

Parameters:
request_p - HttpServletRequest
changedFields_p - optional return map of changed fields, can be null. If compareMap_p is null, compares to the previous value
compareMap_p - optional map with original map to comapre to, can be null
fIgnoreErrors_p - boolean disable error collection for pure updates
Returns:
true = all fields are valid, false = one or more fields are invalid
Throws:
Exception

getFieldJSErrorCtrlID

public 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.

Parameters:
field_p -
Returns:
a String

getSafeFieldError

public String getSafeFieldError(OwField field_p)
                         throws Exception
writes a error message for the requested field, if the field contained an invalid value after user edited it.

Parameters:
field_p - the requested field
Returns:
error string or an empty string if field was valid
Throws:
Exception

resetErrors

public void resetErrors()
Clear the error maps

Since:
3.0.0.0

renderErrors

public String renderErrors()
                    throws Exception
Render all errors collected by this OwFieldManager object

Returns:
- a String object representing the HTML code for errors rendering
Throws:
Exception
Since:
3.0.0.0

clearFieldError

public 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

Parameters:
field_p -
Since:
2.5.2.0

setFieldError

public void setFieldError(OwField field_p,
                          String strError_p)
Sets the given error message for the given field.

Parameters:
field_p -
strError_p -
Since:
2.5.2.0

getUpdateStatus

public boolean getUpdateStatus()
get the status after the last update

Returns:
boolean true = update was OK, all fields are valid, false = update caused errors, one or more fields are invalid

updateFieldInternal

protected abstract Object updateFieldInternal(javax.servlet.http.HttpServletRequest request_p,
                                              OwFieldDefinition fieldDef_p,
                                              Object value_p,
                                              String strID_p)
                                       throws Exception
update the property value upon request and validates the new value. Updates the object, which was displayed in a form using the getEditHTML(...) code. Throws Exception if new value could not be validated

Parameters:
request_p - HttpServletRequest
fieldDef_p - OwFieldDefinition definition of field
value_p - Object old Value
strID_p - ID of the HTML element
Throws:
Exception

attachFieldControlByClass

public abstract void attachFieldControlByClass(String strFieldClassName_p,
                                               OwFieldManagerControl control_p,
                                               Node configNode_p)
                                        throws Exception
attach a field control to the fieldmanager

Parameters:
strFieldClassName_p - class name of the field that uses the control
control_p - OwFieldManagerControl that renders the field
configNode_p - DOM Node to the configuration XML for the control, or null to use defaults
Throws:
Exception

attachFieldControlByType

public abstract void attachFieldControlByType(String strJavaClassName_p,
                                              OwFieldManagerControl control_p,
                                              Node configNode_p)
                                       throws Exception
attach a field control to the fieldmanager

Parameters:
strJavaClassName_p - java type of the field that uses the control
control_p - OwFieldManagerControl that renders the field
configNode_p - DOM Node to the configuration XML for the control, or null to use defaults
Throws:
Exception

getMimeManager

public abstract OwMimeManager getMimeManager()
get a reference to a MIME manager that can be used to render objects

Returns:
OwMimeManager

reset

public void reset()
clear the map before you call insert... methods, otherwise the map would increase to infinite

NOTE: Never forget to call this function in your onRender Method

Since:
3.2.0.0

updateExternalFormTarget

public boolean updateExternalFormTarget(javax.servlet.http.HttpServletRequest request_p,
                                        boolean fSave_p)
                                 throws Exception
update the view after a view event (caused by getEditableViewEventURL), so it can set its form fields

Overrides:
updateExternalFormTarget in class OwEventTarget
Parameters:
request_p - HttpServletRequest
fSave_p - boolean true = save the changes of the form data, false = just update the form data, but do not save
Returns:
true = field data was valid, false = field data was invalid
Throws:
Exception

setExternalFormTarget

public void setExternalFormTarget(OwEventTarget eventtarget_p)
                           throws Exception
override the internal OwEditable with an external one, must be called BEFORE view is attached.
NOTE: By default, view will render its own form, unless you call setEditable When setting an external OwEditable, the view will not render a own form, but use the form name of the given OwEditable. ==> Several form views can update each other.

Overrides:
setExternalFormTarget in class OwEventTarget
Parameters:
eventtarget_p - OwEventTarget
Throws:
Exception

getFormName

public String getFormName()
get the form used for the template edit fields Returns the internal render form or the external one if you called setFormName.

Overrides:
getFormName in class OwEventTarget
Returns:
String form name

insertLabel

public abstract void insertLabel(Writer w_p,
                                 boolean readOnlyView_p,
                                 boolean readOnly_p,
                                 OwProperty property_p,
                                 String suffix_p,
                                 boolean writeLabel_p)
                          throws Exception
Renders a property control label on the given Writer

Parameters:
w_p - Writer
readOnlyView_p - Read only view flag
readOnly_p - Read only property flag
property_p - Property to be rendered
suffix_p - String
writeLabel_p - boolean Write Label
Throws:
Exception


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.