public class OwNumberFieldControl extends OwFieldManagerControl
Field control implementation for Number
based fields.
The field rendering and updating relies on Java's NumberFormat
.
Additional configuration can be specified through a NumberFormat
XML configuration element to designate a DecimalFormat
format pattern string.
The field control tries to enforce a parsed Number
concrete type for the following
Java based types : Integer
, Long
, Double
,
Float
, BigInteger
and BigDecimal
.
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 |
ARRAY_ITEM_INDEX_KEY
query string for the selected array item
|
static int |
DEFAULT_SIZE
default field size
|
static String |
FIELD_ID_KEY
query string for the selected field
|
Constructor and Description |
---|
OwNumberFieldControl() |
Modifier and Type | Method and Description |
---|---|
protected void |
addContainmentError(String id_p,
int errCount_p) |
protected int |
calculateFieldSize(OwFieldDefinition fieldDef_p)
(Overridable)
Returns the calculated field size (maximum amount of characters
entering into field) for the given field definition.
|
protected void |
clearFieldError(String id_p)
Clears the errors associated with the given field ID.
|
protected void |
clearMarkedArrayItemErrors()
Removes errors that were marked for deletion and adjusts the already existing indexes.
|
protected String |
createParseIndexedError(String numberString_p,
int index_p) |
protected int |
fieldContainmentCount(String id_p) |
protected String |
fieldContainmentId(String id_p) |
protected String |
getExternalComplexFieldIdDelimiter()
The string ID delimiter used to separate the ID of an externally generated
ID of a complex field.
The children of complex fields must be properly detected handled by this field control. |
protected String |
getFieldError(String id_p) |
protected String |
getValueIndexTitle(String strID_p) |
void |
init(OwFieldManager fieldmanager_p,
Node configNode_p)
Initializes this field control with the configured number format.
If no number format is configured the default locale NumberFormat is used. |
protected void |
insertAddArrayItemLink(Writer w_p,
OwFieldDefinition fieldDef_p,
String strID_p)
Adds element addition link for array fields.
|
void |
insertEditField(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.
|
void |
insertReadOnlyField(Writer w_p,
OwFieldDefinition fieldDef_p,
Object value_p)
format and displays the value attached to the PropertyClass in HTML
|
protected void |
insertRemoveArrayItemLink(Writer w_p,
OwFieldDefinition fieldDef_p,
int index_p,
String strID_p)
Adds element removal link for array fields.
|
protected void |
insertSingleEditField(Writer w_p,
OwFieldDefinition fieldDef_p,
Object value_p,
String id_p,
String errorFieldId_p)
Inserts a single value, editable HTML control.
|
void |
insertSingleReadOnlyField(Writer w_p,
OwFieldDefinition fieldDef_p,
String id_p,
Object value_p)
Inserts a single-value non-editable HTML control.
|
protected boolean |
isComplexChildId(String strID_p) |
protected boolean |
isErrorContainment(String id_p) |
protected boolean |
isErrorField(String id_p) |
protected boolean |
isMarkedForClear(String id_p) |
protected void |
markArrayItemErrorForClear(String id_p,
String fieldId_p,
int index_p,
int arraySize_p)
Marks the array item with the give ID for deletion.
|
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 void |
setFieldManagerError(String strID_p,
String error_p)
Sets the given error in the current field manager.
This method handles the complex child fields by setting the error for the parent field. |
protected void |
setInternalFieldError(String id_p,
String error_p)
Register an error for a given field ID.
|
Object |
updateField(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 |
updateSingleField(javax.servlet.http.HttpServletRequest request_p,
OwFieldDefinition fieldDef_p,
Object value_p,
String strID_p,
boolean updateErrors_p)
Updates a single value field.
|
protected Number |
validateNumber(String id_p,
Number value_p,
OwFieldDefinition fieldDef_p,
boolean updateErrors_p)
Validates a
Number value against a given OwFieldDefinition . |
getFieldManager, getFormEventFunction, getFormEventURL, getFormName, getFormTarget, init, insertLabel
attach, detach, disableRequestListener, enableRequestListener, getAjaxEventURL, getContext, getEventURL, getFormEventFunction, getFormEventURL, getID, onExternalRequest, onFormEvent, onRequest, setExternalFormTarget, updateExternalFormTarget
public static final String ARRAY_ITEM_INDEX_KEY
public static final String FIELD_ID_KEY
public static final int DEFAULT_SIZE
public void insertEditField(Writer w_p, OwFieldDefinition fieldDef_p, OwField field_p, String strID_p) throws Exception
OwFieldManagerControl
insertEditField
in class OwFieldManagerControl
w_p
- Writer object to write HTML tofieldDef_p
- OwFieldDefinitionfield_p
- OwField Value to be displayedstrID_p
- ID of the HTML elementException
protected void insertAddArrayItemLink(Writer w_p, OwFieldDefinition fieldDef_p, String strID_p) throws Exception
FIELD_ID_KEY
specified parameter.w_p
- the writer objectfieldDef_p
- - the field definition objectstrID_p
- ID of the array fieldIOException
Exception
protected void insertRemoveArrayItemLink(Writer w_p, OwFieldDefinition fieldDef_p, int index_p, String strID_p) throws IOException, Exception
FIELD_ID_KEY
specified parameter.w_p
- - the Writer
object.fieldDef_p
- - the OwFieldDefinition
object.strID_p
- ID of the array fieldIOException
Exception
public void onDeleteArrayItem(javax.servlet.http.HttpServletRequest request_p) throws Exception
Exception
public void onAddArrayItem(javax.servlet.http.HttpServletRequest request_p) throws Exception
Exception
protected int calculateFieldSize(OwFieldDefinition fieldDef_p) throws Exception
By default this implementation returns DEFAULT_SIZE
constant
fieldDef_p
- OwFieldDefinition of the fieldException
protected String getValueIndexTitle(String strID_p)
strID_p
- protected void insertSingleEditField(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p, String id_p, String errorFieldId_p) throws Exception
w_p
- fieldDef_p
- value_p
- id_p
- Exception
public void insertReadOnlyField(Writer w_p, OwFieldDefinition fieldDef_p, Object value_p) throws Exception
OwFieldManagerControl
insertReadOnlyField
in class OwFieldManagerControl
w_p
- Writer object to write HTML tofieldDef_p
- OwFieldDefinition definition of fieldvalue_p
- Object Value to be displayedException
public void insertSingleReadOnlyField(Writer w_p, OwFieldDefinition fieldDef_p, String id_p, Object value_p) throws Exception
w_p
- fieldDef_p
- id_p
- value_p
- Exception
public Object updateField(javax.servlet.http.HttpServletRequest request_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p) throws Exception
OwFieldManagerControl
updateField
in class OwFieldManagerControl
request_p
- HttpServletRequestfieldDef_p
- OwFieldDefinitionvalue_p
- Object old ValuestrID_p
- ID of the HTML elementException
protected boolean isComplexChildId(String strID_p)
strID_p
- true
if the given ID is an externally generated complex child field ID
false
otherwisegetExternalComplexFieldIdDelimiter()
protected void setFieldManagerError(String strID_p, String error_p)
strID_p
- the ID of the control to set the error forerror_p
- the error text to set for the given controlisComplexChildId(String)
protected String getExternalComplexFieldIdDelimiter()
isComplexChildId(String)
which checks for the occurrence of the an external ID delimiter specified by this method.protected String createParseIndexedError(String numberString_p, int index_p)
numberString_p
- an erroneous number Stringindex_p
- the error indexprotected Number validateNumber(String id_p, Number value_p, OwFieldDefinition fieldDef_p, boolean updateErrors_p) throws Exception
Number
value against a given OwFieldDefinition
.
If the value is not valid an error field will be recorded for the given ID.id_p
- value_p
- fieldDef_p
- Exception
- if an error occurs during validationsetInternalFieldError(String, String)
protected final void setInternalFieldError(String id_p, String error_p)
id_p
- String field IDerror_p
- String error messageprotected final void addContainmentError(String id_p, int errCount_p)
protected final void clearFieldError(String id_p) throws Exception
id_p
- Exception
protected final void markArrayItemErrorForClear(String id_p, String fieldId_p, int index_p, int arraySize_p) throws Exception
id_p
- fieldId_p
- index_p
- arraySize_p
- Exception
protected final void clearMarkedArrayItemErrors() throws Exception
Exception
protected final boolean isErrorField(String id_p)
id_p
- true
if there are registered errors for the given field idfalse
otherwiseprotected final int fieldContainmentCount(String id_p)
protected final boolean isErrorContainment(String id_p)
protected final boolean isMarkedForClear(String id_p)
protected final String getFieldError(String id_p)
id_p
- isErrorField(String)
returns false)
the hard-coded "NO ERROR" String is returned.public Object updateSingleField(javax.servlet.http.HttpServletRequest request_p, OwFieldDefinition fieldDef_p, Object value_p, String strID_p, boolean updateErrors_p) throws Exception
request_p
- fieldDef_p
- value_p
- strID_p
- m_numberFormat
)Exception
public void init(OwFieldManager fieldmanager_p, Node configNode_p) throws Exception
NumberFormat
is used.init
in class OwFieldManagerControl
fieldmanager_p
- configNode_p
- Exception
Copyright © 2014 Alfresco Business Solutions. All Rights Reserved.