com.wewebu.ow.server.app
Class OwStandardFieldManager

java.lang.Object
  extended by com.wewebu.ow.server.ui.OwEventTarget
      extended by com.wewebu.ow.server.app.OwFieldManager
          extended by com.wewebu.ow.server.app.OwStandardFieldManager

public class OwStandardFieldManager
extends OwFieldManager

Standard Implementation of the Property User Interface.
Displays Property as HTML and creates HTML Form Elements for editing properties, also performs validation.
NOTE: This class is instantiated once for a block of properties. is only one static instance of this class in one application.

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
static String ARRAY_ITEM_INDEX_KEY
          query string for the selected array item
protected static String COMPLEX_ID_DELIMITER
          delimiter to build complex id's
static String FIELD_ID_KEY
          query string for the selected field
protected  DateFormat m_DateFormat
           
protected  DateFormat m_DateWithoutTimeFormat
           
protected  int m_defMaxStringSize
          value of input fields where MAXLENGTH
protected  Map m_FieldCtrlMap
          map of OwFieldManagerControl controls
protected  OwMimeManager m_MimeManager
          a reference to a mimemanager that can be used to render objects
protected  NumberFormat m_NumberFormat
           
protected  boolean m_restoreFromRequestStrategy
          use default restore mechanism or restore from request strategy (for invalid field values)
protected  int m_textareaThreshold
          threshold of string length for a textarea, below this threshold a textfield is rendered
protected  DateFormat m_TimeFormat
           
static String MAX_STRING_SIZE_CONFIG_NODE
          configuration node name for the max size of string input fields ("MAXLENGTH" attribute)
static String THRESHOLD_CONFIG_NODE
          threshold config node of string length for a textarea, below this threshold a textfield is rendered
 
Fields inherited from class com.wewebu.ow.server.app.OwFieldManager
m_externalFormEventTarget, m_FieldErrors, m_ids2displayNames, m_MainContext, m_ObjectMap
 
Constructor Summary
OwStandardFieldManager()
           
 
Method Summary
 void attachFieldControlByClass(String strFieldClassName_p, OwFieldManagerControl control_p, Node configNode_p)
          attach a field control to the fieldmanager
 void attachFieldControlByType(String strJavaClassName_p, OwFieldManagerControl control_p, Node configNode_p)
          attach a field control to the fieldmanager
protected  void attachFieldControlsFromConfiguration()
          read XML configuration and attach the field controls
protected  OwComboModel createComboBoxModel(OwFieldDefinition fieldDef_p, Object value_p, boolean fAllowEmptyField_p)
          Creates a model for combobox.
 void detach()
          detach from event target map
protected  DateFormat getDateFormater()
          get the formatter used for dates
protected  DateFormat getDateWithoutTimeFormater()
          get the formatter used for time
 OwField getField(String complexid_p)
          get the field from the given complex ID
 OwFieldManagerControl getFieldControlByClass(String strFieldClassName_p)
          get a field control by the given field class name
 OwFieldManagerControl getFieldControlByType(String strJavaClassName_p)
          get a field control by the given java class type
 OwMimeManager getMimeManager()
          get a reference to a mimemanager that can be used to render objects
protected  NumberFormat getNumberFormater()
          get the formatter used for numbers
protected  DateFormat getTimeFormater()
          get the formatter used for time
protected  String getValueIndexTitle(String strID_p)
           
protected  void init()
          init the target after the context is set.
 void insertChoiceListControl(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p, boolean fAllowEmptyField_p)
          Insert choice list for enum fields as default HTML single selectable list.
protected  void insertEditableBoolean(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p)
          Insert a field for editing boolean properties, the rendered input field is preset with three CSS classes for customization.
protected  void insertEditableString(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p)
          Insert a HTML input text field, which depends on the max value size of the property renders a single line Textfield or a multi line Textarea.
protected  void insertEditFieldInternal(Writer w_p, OwFieldDefinition fieldDef_p, OwField field_p, String strID_p)
          format and displays the value attached to the PropertyClass in HTML for use in a HTML Form.
 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.
value type are considered at rendering time.
protected  void insertReadOnlyFieldInternal(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p)
          formates and displays the value attached to the PropertyClass in HTML
protected  void insertSingleComplexEditFieldInternal(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p)
          insert a complex field
protected  void insertSingleComplexReadOnlyFieldInternal(Writer w_p, OwFieldDefinition fieldDef_p, Object[] value_p)
          Inserts a read only complex field
 void insertSingleEditFieldInternal(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p)
          Render a single value editing.
 void insertSingleReadOnlyFieldInternal(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p)
          Render a single read-only value
 void onAddArrayItem(javax.servlet.http.HttpServletRequest request_p)
          called when user clicks to add an array item
 void onDeleteArrayItem(javax.servlet.http.HttpServletRequest request_p)
          called when user clicks to delete an array item
protected  Date parseDate(Object value_p, String strDateFormat_p)
          Helper to parse an object to a java.util.Date, which will simply cast the object or use it together with the provided date format in a parse operation.
 void reset()
          clear the map before you call insert...
protected  Object updateComplexSingleFieldInternal(javax.servlet.http.HttpServletRequest request_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p)
          update a single complex field type
protected  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.
 Object updateSingleFieldInternal(javax.servlet.http.HttpServletRequest request_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p)
          update a single value of a property value upon request and validates the new value.
protected  void validateValue(Object value_p, OwFieldDefinition fieldDef_p)
           
protected  void writeAddMultiValueItemLink(Writer w_p, OwFieldDefinition fieldDef_p, String strID_p)
          Overridable method to insert the "Add" Link after a multi-valued field.
protected  void writeRemoveMultiValueItemLink(Writer w_p, OwFieldDefinition fieldDef_p, int index_p, String strID_p)
          Overridable method to insert the "Delete" Link after each item of a multi-valued field.
 
Methods inherited from class com.wewebu.ow.server.app.OwFieldManager
clearFieldError, computeChangedFields, getConfigNode, getFieldJSErrorCtrlID, getFieldProvider, getFocusControlID, getFormName, getFormTarget, getSafeFieldError, getUpdateStatus, init, insertEditField, insertReadOnlyField, isFieldProviderName, isFieldProviderType, renderErrors, resetErrors, safeEqual, setExternalFormTarget, setFieldError, setFieldProvider, setFocusControlID, update, update, updateExternalFormTarget
 
Methods inherited from class com.wewebu.ow.server.ui.OwEventTarget
attach, 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

ARRAY_ITEM_INDEX_KEY

public static final String ARRAY_ITEM_INDEX_KEY
query string for the selected array item

See Also:
Constant Field Values

FIELD_ID_KEY

public static final String FIELD_ID_KEY
query string for the selected field

See Also:
Constant Field Values

THRESHOLD_CONFIG_NODE

public static final String THRESHOLD_CONFIG_NODE
threshold config node of string length for a textarea, below this threshold a textfield is rendered

See Also:
Constant Field Values

MAX_STRING_SIZE_CONFIG_NODE

public static final String MAX_STRING_SIZE_CONFIG_NODE
configuration node name for the max size of string input fields ("MAXLENGTH" attribute)

See Also:
Constant Field Values

COMPLEX_ID_DELIMITER

protected static final String COMPLEX_ID_DELIMITER
delimiter to build complex id's

See Also:
Constant Field Values

m_DateFormat

protected DateFormat m_DateFormat

m_TimeFormat

protected DateFormat m_TimeFormat

m_DateWithoutTimeFormat

protected DateFormat m_DateWithoutTimeFormat

m_NumberFormat

protected NumberFormat m_NumberFormat

m_FieldCtrlMap

protected Map m_FieldCtrlMap
map of OwFieldManagerControl controls


m_MimeManager

protected OwMimeManager m_MimeManager
a reference to a mimemanager that can be used to render objects


m_textareaThreshold

protected int m_textareaThreshold
threshold of string length for a textarea, below this threshold a textfield is rendered


m_defMaxStringSize

protected int m_defMaxStringSize
value of input fields where MAXLENGTH

Since:
3.2.0.0

m_restoreFromRequestStrategy

protected boolean m_restoreFromRequestStrategy
use default restore mechanism or restore from request strategy (for invalid field values)

Constructor Detail

OwStandardFieldManager

public OwStandardFieldManager()
Method Detail

init

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

Overrides:
init in class OwFieldManager
Throws:
Exception

attachFieldControlsFromConfiguration

protected void attachFieldControlsFromConfiguration()
                                             throws Exception
read XML configuration and attach the field controls

Throws:
Exception

getMimeManager

public OwMimeManager getMimeManager()
get a reference to a mimemanager that can be used to render objects

Specified by:
getMimeManager in class OwFieldManager
Returns:
OwMimeManager

getNumberFormater

protected NumberFormat getNumberFormater()
get the formatter used for numbers

Returns:
NumberFormat

getDateFormater

protected DateFormat getDateFormater()
get the formatter used for dates

Returns:
the current DateFormat for date conversions

getTimeFormater

protected DateFormat getTimeFormater()
get the formatter used for time

Returns:
the current DateFormat for time conversions

getDateWithoutTimeFormater

protected DateFormat getDateWithoutTimeFormater()
get the formatter used for time

Returns:
the current DateFormat for time conversions

attachFieldControlByType

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

Specified by:
attachFieldControlByType in class OwFieldManager
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

attachFieldControlByClass

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

Specified by:
attachFieldControlByClass in class OwFieldManager
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

getFieldControlByType

public OwFieldManagerControl getFieldControlByType(String strJavaClassName_p)
get a field control by the given java class type

Parameters:
strJavaClassName_p -
Returns:
OwFieldManagerControl

getFieldControlByClass

public OwFieldManagerControl getFieldControlByClass(String strFieldClassName_p)
get a field control by the given field class name

Parameters:
strFieldClassName_p -
Returns:
OwFieldManagerControl

detach

public void detach()
detach from event target map

Overrides:
detach in class OwEventTarget

insertReadOnlyFieldInternal

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

Specified by:
insertReadOnlyFieldInternal in class OwFieldManager
Parameters:
w_p - Writer object to write HTML to
fieldDef_p - OwFieldDefinition definition of field
value_p - Object Value to be displayed
Throws:
Exception

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

Overrides:
reset in class OwFieldManager

insertSingleReadOnlyFieldInternal

public void insertSingleReadOnlyFieldInternal(Writer w_p,
                                              OwFieldDefinition fieldDef_p,
                                              Object value_p)
                                       throws Exception

Render a single read-only value

Parameters:
w_p - Writer used for writing the rendering
fieldDef_p - OwFieldDefinition of property for which the control is rendered
value_p - Object reference to the value of the property
Throws:
Exception

insertChoiceListControl

public void insertChoiceListControl(Writer w_p,
                                    OwFieldDefinition fieldDef_p,
                                    Object value_p,
                                    String strID_p,
                                    boolean fAllowEmptyField_p)
                             throws Exception
Insert choice list for enum fields as default HTML single selectable list. Depending on the class configured in owbootstrap.xml, the rendered control has preset CSS classes for customizing :

Parameters:
w_p - Writer for writing the rendering
fieldDef_p - OwFieldDefinition of property
value_p - Object to display with given enum
strID_p - String for ID attribute of HTML control
fAllowEmptyField_p - boolean true = add a empty field to the list
Throws:
Exception

createComboBoxModel

protected OwComboModel createComboBoxModel(OwFieldDefinition fieldDef_p,
                                           Object value_p,
                                           boolean fAllowEmptyField_p)
                                    throws Exception
Creates a model for combobox.

Parameters:
fieldDef_p - - fieldDefinition
value_p - - the value of the object
fAllowEmptyField_p - - allow empty value flag.
Returns:
OwComboModel - the model of the combo to be rendered.
Throws:
Exception
Since:
3.0.0.0

insertEditFieldInternal

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

Specified by:
insertEditFieldInternal in class OwFieldManager
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

writeRemoveMultiValueItemLink

protected void writeRemoveMultiValueItemLink(Writer w_p,
                                             OwFieldDefinition fieldDef_p,
                                             int index_p,
                                             String strID_p)
                                      throws IOException,
                                             Exception
Overridable method to insert the "Delete" Link after each item of a multi-valued field.

Parameters:
w_p - The writer to write to
fieldDef_p - - the field definition object, can be null
index_p - The index of the item inside the field
strID_p - The ID of the field
Throws:
Exception
IOException
Since:
3.0.0.0

writeAddMultiValueItemLink

protected void writeAddMultiValueItemLink(Writer w_p,
                                          OwFieldDefinition fieldDef_p,
                                          String strID_p)
                                   throws IOException,
                                          Exception
Overridable method to insert the "Add" Link after a multi-valued field.

Parameters:
w_p - The writer to write to
fieldDef_p - - the OwFieldDefinition object. Can be null.
strID_p - The ID of the field
Throws:
Exception
IOException
Since:
3.0.0.0

getField

public OwField getField(String complexid_p)
get the field from the given complex ID

Overrides:
getField in class OwFieldManager
Parameters:
complexid_p - ....., e.g. 1254993.1.5.2.3
Returns:
OwField

onDeleteArrayItem

public void onDeleteArrayItem(javax.servlet.http.HttpServletRequest request_p)
                       throws Exception
called when user clicks to delete an array item

Throws:
Exception

onAddArrayItem

public void onAddArrayItem(javax.servlet.http.HttpServletRequest request_p)
                    throws Exception
called when user clicks to add an array item

Throws:
Exception

insertSingleComplexReadOnlyFieldInternal

protected void insertSingleComplexReadOnlyFieldInternal(Writer w_p,
                                                        OwFieldDefinition fieldDef_p,
                                                        Object[] value_p)
                                                 throws Exception
Inserts a read only complex field

Parameters:
w_p - output writer
fieldDef_p - the complex field definition
value_p - the complex value (must be an
Throws:
Exception

insertSingleComplexEditFieldInternal

protected void insertSingleComplexEditFieldInternal(Writer w_p,
                                                    OwFieldDefinition fieldDef_p,
                                                    Object value_p,
                                                    String strID_p)
                                             throws Exception
insert a complex field

Parameters:
w_p -
fieldDef_p -
value_p -
strID_p -
Throws:
Exception

insertSingleEditFieldInternal

public void insertSingleEditFieldInternal(Writer w_p,
                                          OwFieldDefinition fieldDef_p,
                                          Object value_p,
                                          String strID_p)
                                   throws Exception

Render a single value editing. Depending on the type of the property different edit controls are rendered. All controls have the default Workdesk CSS class for improving/customizing the rendering.

Also it is tried to format the value_p to a number and then the control is extended with an additional CSS class.

CSS class(es) preset for the control:

Parameters:
w_p - Writer used for writing the rendering
fieldDef_p - OwFieldDefinition of property for which the control is rendered
value_p - Object reference to the value of the property
strID_p - String representing the HTML name/id attribute
Throws:
Exception

parseDate

protected Date parseDate(Object value_p,
                         String strDateFormat_p)
Helper to parse an object to a java.util.Date, which will simply cast the object or use it together with the provided date format in a parse operation.

This method will return null, if conversion into Date representation fails or the provided value is null

Parameters:
value_p - Object which should be interpreted as Date value
strDateFormat_p - String representing the format which should be used for parse operation
Returns:
java.util.Date representation, or null if could transform object into a date value
Since:
3.1.0.3

getValueIndexTitle

protected String getValueIndexTitle(String strID_p)
Parameters:
strID_p -
Returns:
the value index based title information for array and complex values
Since:
3.0.0.0

insertEditableString

protected void insertEditableString(Writer w_p,
                                    OwFieldDefinition fieldDef_p,
                                    Object value_p,
                                    String strID_p)
                             throws Exception
Insert a HTML input text field, which depends on the max value size of the property renders a single line Textfield or a multi line Textarea.

For better customization possibilities the rendered input fields have following three CSS (Cascading Style Sheet) classes:

Parameters:
w_p - Writer which is used to write out the rendering
fieldDef_p - OwFieldDefinition of the Property to be rendered
value_p - Object that should be a String which is the default value of the Textfield
strID_p - String representing the HTML name/ID attribute
Throws:
Exception

insertEditableBoolean

protected void insertEditableBoolean(Writer w_p,
                                     OwFieldDefinition fieldDef_p,
                                     Object value_p,
                                     String strID_p)
                              throws Exception
Insert a field for editing boolean properties, the rendered input field is preset with three CSS classes for customization.

Parameters:
w_p - Writer for writing out the rendering
fieldDef_p - OwFieldDefinition of the property that should be rendered
value_p - Object representing a Boolean or boolean value
strID_p - String used for HTML name/ID of rendered input field
Throws:
Exception

updateFieldInternal

protected 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

Specified by:
updateFieldInternal in class OwFieldManager
Parameters:
request_p - HttpServletRequest
fieldDef_p - OwFieldDefinition definition of field
value_p - Object old Value
strID_p - ID of the HTML element
Throws:
Exception

updateComplexSingleFieldInternal

protected Object updateComplexSingleFieldInternal(javax.servlet.http.HttpServletRequest request_p,
                                                  OwFieldDefinition fieldDef_p,
                                                  Object value_p,
                                                  String strID_p)
                                           throws Exception
update a single complex field type

Parameters:
request_p -
fieldDef_p -
value_p -
strID_p -
Returns:
Object
Throws:
Exception

updateSingleFieldInternal

public Object updateSingleFieldInternal(javax.servlet.http.HttpServletRequest request_p,
                                        OwFieldDefinition fieldDef_p,
                                        Object value_p,
                                        String strID_p)
                                 throws Exception
update a single value of a 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

validateValue

protected void validateValue(Object value_p,
                             OwFieldDefinition fieldDef_p)
                      throws Exception
Parameters:
value_p -
fieldDef_p -
Throws:
Exception

insertLabel

public 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.
value type are considered at rendering time.

Specified by:
insertLabel in class OwFieldManager
Parameters:
w_p - Writer
readOnlyView_p - ReadOnly view
readOnly_p - ReadOnly property
property_p - Property
suffix_p - String
writeLabel_p - write label
Throws:
Exception
Since:
3.2.0.0


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.