com.wewebu.ow.server.settingsimpl
Class OwSettingsPropertyBaseImpl

java.lang.Object
  extended by com.wewebu.ow.server.ui.OwEventTarget
      extended by com.wewebu.ow.server.app.OwSettingsPropertyControl
          extended by com.wewebu.ow.server.settingsimpl.OwSettingsPropertyBaseImpl
All Implemented Interfaces:
OwSettingsProperty
Direct Known Subclasses:
OwSettingsPropertyBoolean, OwSettingsPropertyBPMProxy, OwSettingsPropertyInteger, OwSettingsPropertyKeyBoardMapping, OwSettingsPropertyObject, OwSettingsPropertyRefreshBootConfig, OwSettingsPropertyRefreshClassDescriptions, OwSettingsPropertySort, OwSettingsPropertyStartupPlugin, OwSettingsPropertyString, OwSettingsPropertyStringCombo, OwSettingsPropertyStringConfigurationBox, OwSettingsPropertyWindowPositions

public abstract class OwSettingsPropertyBaseImpl
extends OwSettingsPropertyControl

Base Implementation of the OwSettingsProperty class.

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 static String ITEM_PREFIX
          ID prefix for list values
protected static String ITEM_QUERY_KEY
          query key for the item parameter for the delete event
protected  Object m_defaultValue
          default value of property
protected  OwEventTarget m_externalFormEventTarget
          external form view overrides internal form
protected  boolean m_fList
          true = value is list of values
protected  Node m_propertyDefinitionNode
          the defining node from the plugin descriptors setting set
protected  String m_strError
          a error message for this field, if update failed
protected  String m_strSetName
          set name
protected  Object m_value
          current value of property
 
Fields inherited from interface com.wewebu.ow.server.app.OwSettingsProperty
ITEM_VALUE_NODE
 
Constructor Summary
OwSettingsPropertyBaseImpl()
           
 
Method Summary
protected  void appendSingleValueNode(Node valueRootNode_p, Object value_p)
          overridable, return the given value as a DOM Node for serialization
protected  boolean canAdd()
          check if additional items can be added to the list value
protected  Object createSingleClonedValue(Object oSingleValue_p)
          create a clone out of the given single property value
protected  Object createValue(Node valueNode_p)
          to create a single value for the given definition node NOTE: Reads the value from the ITEM_VALUE_NODE node.
protected  List createValueList(Node valueNode_p)
          create a list of values, if property is a list
protected  String extractIDIndex(String strID_p, String indexSeparator_p, int indexElement_p)
           
protected  Object getDefaultListItemValue()
          overridable to create a default value for list properties
 String getDisplayName()
          get display name of property
 String getFormName()
          get the form used for the edit fields
 OwEventTarget getFormTarget()
          get the target, that is used for form data and renders form
 String getHelpPath()
          get optional help path for the control
protected  int getMaxListSize()
          get the maximum count of list items allowed
 String getName()
          get ID of property
protected  Node getPropertyDefinitionNode()
          get a reference to the property definition node
 String getPropertyError()
          Gets a error message for this field
 String getSafePropertyError()
          gets a error message for this field, if update failed, clears the message automatically
protected  Object getSingleValue(Node valueNode_p)
          overridable to create a single value for the given node
protected  Object getSingleValueFromRequest(javax.servlet.http.HttpServletRequest request_p, String strID_p)
          overridable to apply changes on a submitted form
 Object getValue()
          get current value of property
 Node getValueNode(Document doc_p)
          return the property value as a DOM Node for serialization
 boolean hasError()
          Check if this property has an error associated, without clear the error message
protected  void init()
          init the target after the context is set.
 void init(Node propertyDefinitionNode_p, Node valueNode_p, String strSetName_p)
          set current value of property, to be overridden
 void insertFormField(Writer w_p)
          insert the property into a HTML form for editing
protected  void insertFormValue(Writer w_p, Object value_p, String strID_p, int iIndex_p)
          overridable to insert a single value into a edit HTML form
 boolean isEditable()
          get flag indicating if property can be edited
 boolean isList()
          get flag indicating list or scalar value
 boolean isModified()
          true = value was modified, false otherwise
 boolean isUser()
          get flag indicating the scope of the property
 void onAdd(javax.servlet.http.HttpServletRequest request_p)
          called when user clicked the add item button for a list property
 void onDelete(javax.servlet.http.HttpServletRequest request_p)
          called when user clicked a delete button on a list entry
 void saved()
          signal that value was saved and modified flag can be reset
 void setDefault()
          set the default value
 void setExternalFormTarget(OwEventTarget eventtarget_p)
          override the internal form with an external one, must be called BEFORE event target is attached.
 void setValue(Object value_p)
          set current value of property, to be overridden
 String toString()
           
 boolean updateExternalFormTarget(javax.servlet.http.HttpServletRequest request_p, boolean fSave_p)
          update the target after a form event, so it can set its form fields
protected  void writeAddNewItemButton(Writer w_p)
          Render the add new item button.
protected  void writeDeleteButton(Writer w_p, int position_p)
          Render the delete button.
 
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, wait, wait, wait
 

Field Detail

m_propertyDefinitionNode

protected Node m_propertyDefinitionNode
the defining node from the plugin descriptors setting set


m_defaultValue

protected Object m_defaultValue
default value of property


m_strSetName

protected String m_strSetName
set name


ITEM_QUERY_KEY

protected static final String ITEM_QUERY_KEY
query key for the item parameter for the delete event

See Also:
Constant Field Values

ITEM_PREFIX

protected static final String ITEM_PREFIX
ID prefix for list values

See Also:
Constant Field Values

m_fList

protected boolean m_fList
true = value is list of values


m_value

protected Object m_value
current value of property


m_strError

protected String m_strError
a error message for this field, if update failed


m_externalFormEventTarget

protected OwEventTarget m_externalFormEventTarget
external form view overrides internal form

Constructor Detail

OwSettingsPropertyBaseImpl

public OwSettingsPropertyBaseImpl()
Method Detail

init

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

Specified by:
init in class OwEventTarget
Throws:
Exception

getHelpPath

public String getHelpPath()
get optional help path for the control

Specified by:
getHelpPath in class OwSettingsPropertyControl
Returns:
JSP path or null if no help is available

getValue

public Object getValue()
get current value of property

Returns:
Object if isList() is true, Object otherwise

createSingleClonedValue

protected Object createSingleClonedValue(Object oSingleValue_p)
create a clone out of the given single property value

Specified by:
createSingleClonedValue in class OwSettingsPropertyControl
Parameters:
oSingleValue_p - single Object value
Returns:
Object

isModified

public boolean isModified()
true = value was modified, false otherwise

Specified by:
isModified in class OwSettingsPropertyControl

saved

public void saved()
signal that value was saved and modified flag can be reset


getDefaultListItemValue

protected Object getDefaultListItemValue()
                                  throws Exception
overridable to create a default value for list properties

Returns:
Object with default value for a new list item
Throws:
Exception

isList

public boolean isList()
get flag indicating list or scalar value

Returns:
boolean true = list value, otherwise scalar

setValue

public void setValue(Object value_p)
set current value of property, to be overridden

Parameters:
value_p - Object

updateExternalFormTarget

public boolean updateExternalFormTarget(javax.servlet.http.HttpServletRequest request_p,
                                        boolean fSave_p)
                                 throws Exception
update the target after a form event, 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

getSingleValueFromRequest

protected Object getSingleValueFromRequest(javax.servlet.http.HttpServletRequest request_p,
                                           String strID_p)
                                    throws Exception
overridable to apply changes on a submitted form

Parameters:
request_p - HttpServletRequest with form data to update the property
strID_p - String the HTML form element ID of the requested value
Throws:
Exception

getSafePropertyError

public String getSafePropertyError()
gets a error message for this field, if update failed, clears the message automatically

Specified by:
getSafePropertyError in class OwSettingsPropertyControl
Returns:
String error message or an empty string

hasError

public boolean hasError()
Description copied from class: OwSettingsPropertyControl
Check if this property has an error associated, without clear the error message

Specified by:
hasError in class OwSettingsPropertyControl
See Also:
OwSettingsPropertyControl.hasError()

getPropertyError

public String getPropertyError()
Description copied from class: OwSettingsPropertyControl
Gets a error message for this field

Specified by:
getPropertyError in class OwSettingsPropertyControl
Returns:
String error message or an empty string
See Also:
OwSettingsPropertyControl.getPropertyError()

insertFormField

public void insertFormField(Writer w_p)
                     throws Exception
insert the property into a HTML form for editing

Specified by:
insertFormField in class OwSettingsPropertyControl
Parameters:
w_p - Writer to write HTML code to
Throws:
Exception

writeAddNewItemButton

protected void writeAddNewItemButton(Writer w_p)
                              throws Exception
Render the add new item button.

Parameters:
w_p - - the Writer object
Throws:
Exception

writeDeleteButton

protected void writeDeleteButton(Writer w_p,
                                 int position_p)
                          throws Exception
Render the delete button.

Parameters:
w_p - - the Writer object
position_p - - the position index
Throws:
Exception
Since:
3.0.0.0

onDelete

public void onDelete(javax.servlet.http.HttpServletRequest request_p)
              throws Exception
called when user clicked a delete button on a list entry

Parameters:
request_p - HttpServletRequest
Throws:
Exception

canAdd

protected boolean canAdd()
check if additional items can be added to the list value


onAdd

public void onAdd(javax.servlet.http.HttpServletRequest request_p)
           throws Exception
called when user clicked the add item button for a list property

Parameters:
request_p - HttpServletRequest
Throws:
Exception

insertFormValue

protected void insertFormValue(Writer w_p,
                               Object value_p,
                               String strID_p,
                               int iIndex_p)
                        throws Exception
overridable to insert a single value into a edit HTML form

Parameters:
w_p - Writer to write HTML code to
value_p - the property value to edit
strID_p - String the ID of the HTML element for use in onApply
iIndex_p - int Index of item if it is a list
Throws:
Exception

getPropertyDefinitionNode

protected Node getPropertyDefinitionNode()
get a reference to the property definition node


setDefault

public void setDefault()
set the default value


getValueNode

public Node getValueNode(Document doc_p)
return the property value as a DOM Node for serialization

Parameters:
doc_p - DOM Document to add to
Returns:
Node

appendSingleValueNode

protected void appendSingleValueNode(Node valueRootNode_p,
                                     Object value_p)
overridable, return the given value as a DOM Node for serialization

Parameters:
valueRootNode_p - root Node of the property
value_p - Object to append as DOM Node

isUser

public boolean isUser()
get flag indicating the scope of the property

Returns:
boolean true = user, false = app scope

isEditable

public boolean isEditable()
get flag indicating if property can be edited

Returns:
boolean true = editable

getDisplayName

public String getDisplayName()
get display name of property

Specified by:
getDisplayName in class OwSettingsPropertyControl
Returns:
String display name

getName

public String getName()
get ID of property

Returns:
String with ID

getFormName

public String getFormName()
get the form used for the edit fields

Overrides:
getFormName in class OwEventTarget
Returns:
String form name

extractIDIndex

protected String extractIDIndex(String strID_p,
                                String indexSeparator_p,
                                int indexElement_p)
Parameters:
strID_p - a field control ID String
indexSeparator_p - numeric index separator of the strID_p
indexElement_p - the index of the string index after strID_p split around indexElement_p
Returns:
the String value index based title information for array and complex values
Since:
3.0.0.0

setExternalFormTarget

public void setExternalFormTarget(OwEventTarget eventtarget_p)
                           throws Exception
override the internal form with an external one, must be called BEFORE event target is attached.
NOTE: By default, view will render its own form, unless you call setFormTarget When setting an external form, 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 to be used for form data
Throws:
Exception

getFormTarget

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

Overrides:
getFormTarget in class OwEventTarget
Returns:
OwEventTarget

getMaxListSize

protected int getMaxListSize()
get the maximum count of list items allowed

Returns:
int max list size or 0 for infinity size

init

public void init(Node propertyDefinitionNode_p,
                 Node valueNode_p,
                 String strSetName_p)
          throws Exception
set current value of property, to be overridden

Parameters:
propertyDefinitionNode_p - the node which defines the property in the plugin descriptors setting
valueNode_p - the node with the current value
strSetName_p - name of the property set for which the property is created
Throws:
Exception

getSingleValue

protected Object getSingleValue(Node valueNode_p)
overridable to create a single value for the given node

Returns:
Object with value

createValue

protected Object createValue(Node valueNode_p)
to create a single value for the given definition node NOTE: Reads the value from the ITEM_VALUE_NODE node.

Returns:
Object with value

createValueList

protected List createValueList(Node valueNode_p)
create a list of values, if property is a list

Parameters:
valueNode_p - Node with child value nodes
Returns:
List of Objects representing values

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.