public class ValuesManager extends BaseClass implements HasAsyncValidationReplyHandlers, HasHiddenValidationErrorsHandlers, HasMemberSynchronizedHandlers
If a single logical form needs to be separated into multiple DynamicForm instances for Layout purposes (for example, spanning one logical form across multiple Tabs), a ValuesManager can be used to make the forms act as one logical form, supporting all value-related APIs otherwise called on DynamicForm directly.
A ValuesManager has no visual representation - it is strictly a logical entity, and the
member forms provide the user interface. You can initialize a ValuesManager with a set of member forms (by setting
members
at init) or add and remove member forms
dynamically.
Calling setValues()
on a ValuesManager
will automatically route new field values to whichever member form is showing an editor for that field. Likewise,
calling validate()
will validate all member forms, and
saveData()
will initiate a save operation which
aggregates values from all member forms.
Like a DynamicForm, a ValuesManager can be databound by setting dataSource
. In this case all member forms must also be
bound to the same DataSource.
In general, when working with a ValuesManager and its member forms, call APIs on the ValuesManager whenever you are dealing with values that span multiple forms, and only call APIs on member forms that are specific to that form or its fields.
Note that, just as a DynamicForm can track values that are not shown in any FormItem, a ValuesManager may track values for which there is no FormItem in any member form. However, when using a ValuesManager these extra values are only allowed on the ValuesManager itself. Member forms will not track values for which they do not have FormItems.
config, configOnly, factoryCreated, factoryProperties, id, scClassName
Constructor and Description |
---|
ValuesManager() |
ValuesManager(com.google.gwt.core.client.JavaScriptObject jsObj) |
Modifier and Type | Method and Description |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addAsyncValidationReplyHandler(AsyncValidationReplyHandler handler)
Add a asyncValidationReply handler.
|
com.google.gwt.event.shared.HandlerRegistration |
addHiddenValidationErrorsHandler(HiddenValidationErrorsHandler handler)
Add a hiddenValidationErrors handler.
|
void |
addMember(Canvas member) |
void |
addMember(DynamicForm member)
Add a new member to this valuesManager.
|
void |
addMember(java.lang.String member)
Add a new member to this valuesManager.
|
com.google.gwt.event.shared.HandlerRegistration |
addMemberSynchronizedHandler(MemberSynchronizedHandler handler)
Add a memberSynchronized handler.
|
com.google.gwt.event.shared.HandlerRegistration |
addSubmitValuesHandler(SubmitValuesHandler handler)
Add a submitValues handler.
|
void |
cancel()
This method exists for clean integration with existing server frameworks that have a 'cancel'
feature which typically clears session state associated with the form.
|
void |
cancel(DSRequest requestProperties)
This method exists for clean integration with existing server frameworks that have a 'cancel'
feature which typically clears session state associated with the form.
|
void |
clearErrors(boolean showErrors)
Clears all errors from member forms.
|
void |
clearFieldErrors(java.lang.String fieldName,
boolean show)
Clear all validation errors associated with some field in this form
|
void |
clearValue(java.lang.String fieldName)
Clear the value for some field.
|
void |
clearValues()
Clear out all the values managed by this values manager.
|
com.google.gwt.core.client.JavaScriptObject |
create() |
void |
editNewRecord()
Prepare to edit a new record by clearing the current set of values (or replacing them with initialValues if specified).
|
void |
editNewRecord(java.util.Map initialValues)
Prepare to edit a new record by clearing the current set of values (or replacing them with initialValues if specified).
|
void |
editNewRecord(Record initialValues)
Prepare to edit a new record by clearing the current set of values (or replacing them with initialValues if specified).
|
void |
editRecord(Record record)
Edit an existing record.
|
void |
editSelectedData(ListGrid selectionComponent)
Edit the record selected in the specified selection component (typically a
ListGrid ). |
void |
fetchData()
Retrieve data that matches the provided criteria, and edit the first record returned
|
void |
fetchData(Criteria criteria) |
void |
fetchData(Criteria criteria,
DSCallback callback) |
void |
fetchData(Criteria criteria,
DSCallback callback,
DSRequest requestProperties)
Retrieve data that matches the provided criteria, and edit the first record returned
|
void |
filterData()
Retrieve data that matches the provided criteria, and edit the first record returned.
Differs from DynamicForm.fetchData() in that a case insensitive substring
match will be performed against the criteria to retrieve the data. |
void |
filterData(Criteria criteria) |
void |
filterData(Criteria criteria,
DSCallback callback) |
void |
filterData(Criteria criteria,
DSCallback callback,
DSRequest requestProperties)
Retrieve data that matches the provided criteria, and edit the first record returned.
Differs from DynamicForm.fetchData() in that a case insensitive substring
match will be performed against the criteria to retrieve the data. |
java.lang.String |
getAddOperation()
operationId to use when performing add operations. |
java.lang.Boolean |
getAutoSynchronize()
If explicitly set to false, prevents the ValuesManager from automatically propagating data value changes to its members.
|
static ValuesManager |
getById(java.lang.String ID)
Retrieve a ValuesManager by it's global
ID . |
java.util.Map |
getChangedValues()
Returns all values within this DynamicForm that have changed since
DynamicForm.rememberValues() last ran. |
DataSource |
getDataSource()
The DataSource that this component should bind to for default fields and for performing
DSRequest . |
java.lang.Boolean |
getDeepCloneNonFieldValuesOnEdit()
When editing values in this ValuesManager in one or more DataBoundComponents, should we perform a deep clone of values
that are not associated with a field (ie, attributes on the record that do not map to a component field either directly
by name, or by
FormItem.dataPath . |
java.lang.Boolean |
getDeepCloneOnEdit()
Before we start editing the values of this ValuesManager in one or more DataBoundComponents, should we perform a deep
clone of the underlying values.
|
java.lang.Boolean |
getDisableValidation()
If set to true, client-side validators will not run on the form when validate() is called.
|
java.util.Map |
getErrors()
Returns the set of errors for this valuesManager.
|
java.lang.String |
getFetchOperation()
operationId to use when performing fetch operations. |
java.lang.String[] |
getFieldErrors(java.lang.String fieldName)
Returns any validation errors for some field in this valuesManager.
|
FormItem |
getItem(java.lang.String itemID)
Retrieve a
FormItem from this ValuesManager. |
Canvas[] |
getMemberCanvases()
Returns the members of this ValuesManager as an array of Canvas objects.
|
Canvas |
getMemberForField(java.lang.String fieldName)
Given a fieldName or dataPath, this method will find the member responsible for interacting with that field's value.
|
DynamicForm[] |
getMembers()
Returns an array of members in this ValuesManager.
|
java.util.Map |
getOldValues()
Returns the set of values last stored by
DynamicForm.rememberValues() . |
OperatorId |
getOperator()
What operator should be used to combine sub-criteria from member forms when
getValuesAsCriteria() is called? |
static ValuesManager |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
java.util.Map |
getPaletteDefaults()
This method returns a Map of config properties suitable for use as the "defaults"
attribute of a
PaletteNode . |
java.lang.String |
getRemoveOperation()
operationId to use when performing remove operations. |
DSOperationType |
getSaveOperationType()
Default
DSOperationType to be performed when DynamicForm.saveData() is called. |
java.lang.Boolean |
getSuppressValidationErrorCallback()
When calling
saveData() on a form or valuesManager, by
default if the server returns an error code, any callback passed into saveData() will not be fired. |
java.lang.String |
getUpdateOperation()
operationId to use when performing update operations. |
java.lang.Object |
getValue(java.lang.String fieldName)
Return the value of the field.
|
java.lang.String |
getValueAsString(java.lang.String fieldName)
Return the value as String
|
java.util.Map |
getValues()
Returns the current set of values for the values manager instance.
|
AdvancedCriteria |
getValuesAsAdvancedCriteria()
Return an AdvancedCriteria object based on the current set of values within memberForms.
|
AdvancedCriteria |
getValuesAsAdvancedCriteria(TextMatchStyle textMatchStyle)
Return an AdvancedCriteria object based on the current set of values within memberForms.
|
Criteria |
getValuesAsCriteria()
Retrieves the combined
com.smartgwt.client.widgets.form.DynamicForm#getValuesAsCriteria(),criteria values
for all member forms. |
Record |
getValuesAsRecord()
Returns the current set of values for the values manager instance.
|
java.lang.Boolean |
hasErrors()
Are there any errors associated with any fields in this valuesManager?
|
java.lang.Boolean |
hasFieldErrors(java.lang.String fieldName)
Are there any errors associated with a field in this valuesManager?
|
java.lang.Boolean |
isNewRecord()
Returns true if
saveOperationType is
currently "add". |
java.lang.Boolean |
isPendingAsyncValidation()
Is this
ValuesManager waiting for an asynchronous validation to complete? This method will return true
after validate() is called on a component with
server-side validators for some field(s), until the server responds. |
void |
itemChanged(FormItem item,
java.lang.Object newValue)
Handler fired whenever a change to a FormItem fires itemChanged() on one of the member forms.
|
protected void |
onInit_ValuesManager() |
protected void |
onInit() |
com.google.gwt.core.client.JavaScriptObject |
rememberValues()
Make a snapshot of the current set of values, so we can reset to them later.
|
void |
removeMember(Canvas member) |
void |
removeMember(DynamicForm member)
Remove a member form from this valuesManager, so its values are no longer managed by this instance.
|
void |
removeMember(java.lang.String formID)
Remove a member form from this valuesManager, so its values are no longer managed by this instance.
|
void |
removeMembers(DynamicForm... members)
Remove multiple member forms from this valuesManager.
|
void |
resetValues()
Same as
DynamicForm.reset() . |
void |
saveData()
Validate and then save the form's current values to the
DataSource this form is bound
to. |
void |
saveData(DSCallback callback) |
void |
saveData(DSCallback callback,
DSRequest requestProperties)
Validate and then save the form's current values to the
DataSource this form is bound
to. |
void |
setAddOperation(java.lang.String addOperation)
operationId to use when performing add operations. |
void |
setAutoSynchronize(java.lang.Boolean autoSynchronize)
If explicitly set to false, prevents the ValuesManager from automatically propagating data value changes to its members.
|
void |
setDataSource(DataSource dataSource)
The DataSource that this component should bind to for default fields and for performing
DataSource
requests
|
void |
setDeepCloneNonFieldValuesOnEdit(java.lang.Boolean deepCloneNonFieldValuesOnEdit)
When editing values in this ValuesManager in one or more DataBoundComponents, should we perform a deep clone of values
that are not associated with a field (ie, attributes on the record that do not map to a component field either directly
by name, or by
FormItem.dataPath . |
void |
setDeepCloneOnEdit(java.lang.Boolean deepCloneOnEdit)
Before we start editing the values of this ValuesManager in one or more DataBoundComponents, should we perform a deep
clone of the underlying values.
|
void |
setDisableValidation(java.lang.Boolean disableValidation)
If set to true, client-side validators will not run on the form when validate() is called.
|
void |
setErrors(java.util.Map errors,
boolean showErrors)
Setter for validation errors on this form.
|
void |
setFetchOperation(java.lang.String fetchOperation)
operationId to use when performing fetch operations. |
void |
setFieldErrors(java.lang.String fieldName,
java.lang.String[] errors,
boolean showErrors)
Set field validation errors for some field.
|
void |
setFieldErrors(java.lang.String fieldName,
java.lang.String error,
boolean showErrors)
Set field validation error for some field.
|
void |
setOperator(OperatorId operator)
What operator should be used to combine sub-criteria from member forms when
getValuesAsCriteria() is called? |
void |
setRemoveOperation(java.lang.String removeOperation)
operationId to use when performing remove operations. |
void |
setSaveOperationType(DSOperationType saveOperationType)
Default
DSOperationType to be performed when DynamicForm.saveData() is called. |
void |
setSuppressValidationErrorCallback(java.lang.Boolean suppressValidationErrorCallback)
When calling
saveData() on a form or valuesManager, by
default if the server returns an error code, any callback passed into saveData() will not be fired. |
void |
setUpdateOperation(java.lang.String updateOperation)
operationId to use when performing update operations. |
void |
setValue(java.lang.String fieldName,
boolean value)
Set the value for some field.
|
void |
setValue(java.lang.String fieldName,
DataClass value)
Set the value for some field.
|
void |
setValue(java.lang.String fieldName,
DataClass[] value)
Set the value for some field.
|
void |
setValue(java.lang.String fieldName,
java.util.Date value)
Set the value for some field.
|
void |
setValue(java.lang.String fieldName,
double value)
Set the value for some field.
|
void |
setValue(java.lang.String fieldName,
com.google.gwt.core.client.JavaScriptObject value)
Set the value for some field.
|
void |
setValue(java.lang.String fieldName,
java.util.Map value)
Set the value for some field.
|
void |
setValue(java.lang.String fieldName,
Record value)
Set the value for some field.
|
void |
setValue(java.lang.String fieldName,
Record[] value)
Set the value for some field.
|
void |
setValue(java.lang.String fieldName,
java.lang.String value)
Set the value for some field.
|
void |
setValues(java.util.Map values)
Replaces the current values of the ValuesManager and all member components with the values passed in.
|
void |
showErrors()
If this form has any outstanding validation errors, show them now.
This method is called when the set of errors are changed by DynamicForm.setErrors(java.util.Map, boolean) or
DynamicForm.validate() . |
void |
showFieldErrors()
Method to explicitly show the latest set of validation errors present on some field within this ValuesManager.
If the field in question is present as a visible item in a member form, the form item will be redrawn to display the error message(s). |
void |
submit()
submit() is automatically called when a SubmitItem in a
member form is clicked, or if saveOnEnter is set for
some member form, when the "Enter" key is pressed in a text input. |
void |
submit(DSCallback callback) |
void |
submit(DSCallback callback,
DSRequest requestProperties)
submit() is automatically called when a SubmitItem in a
member form is clicked, or if saveOnEnter is set for
some member form, when the "Enter" key is pressed in a text input. |
void |
synchronizeMember(Canvas member)
Update the parameter ValuesManager member to reflect the current values held by the ValuesManager.
|
void |
synchronizeMembers()
Update all of this ValuesManager's members to reflect the current values held by the ValuesManager.
|
void |
synchronizeMembersOnDataPath(java.lang.String dataPath)
Update just those of this ValuesManager's members that have the parameter
dataPath , to reflect the current values held by the ValuesManager. |
java.lang.Boolean |
validate()
Validate the current set of values for this values manager against validators defined in the member forms.
|
java.lang.Boolean |
valuesHaveChanged()
Compares the current set of values with the values stored by the call to the
DynamicForm.rememberValues() method. |
applyFactoryProperties, asSGWTComponent, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getJsObj, getOrCreateJsObj, getRef, getScClassName, getTestInstance, hasAutoAssignedID, internalSetID, internalSetID, isConfigOnly, isCreated, isFactoryCreated, onBind, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setFactoryCreated, setID, setJavaScriptObject, setProperty, setProperty, setProperty, setProperty, setScClassName
public ValuesManager()
public ValuesManager(com.google.gwt.core.client.JavaScriptObject jsObj)
public static ValuesManager getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public java.util.Map getPaletteDefaults()
PaletteNode
. Use it when you need to
work with PaletteNodes indirectly, such when setting up
TileRecord
s that will be used in a
TilePalette
. See
the dev tools overview
for examples of how to
assemble and acquire a suitable defaults object when you are creating a PaletteNode
indirectlypublic com.google.gwt.core.client.JavaScriptObject create()
public void setAddOperation(java.lang.String addOperation)
operationId
to use when performing add operations.addOperation
- New addOperation value. Default value is nullOperations overview and related methods
public java.lang.String getAddOperation()
operationId
to use when performing add operations.Operations overview and related methods
public void setAutoSynchronize(java.lang.Boolean autoSynchronize)
synchronizeMembers()
.
Note : This is an advanced setting
autoSynchronize
- New autoSynchronize value. Default value is nullpublic java.lang.Boolean getAutoSynchronize()
synchronizeMembers()
.public void setDeepCloneNonFieldValuesOnEdit(java.lang.Boolean deepCloneNonFieldValuesOnEdit)
FormItem.dataPath
. If this value is
not explicitly set, it defaults to the value of DataSource.deepCloneNonFieldValuesOnEdit
if there
is a dataSource, or to the value of the static deepCloneNonFieldValuesOnEdit
if there is no dataSource. Like the other deepCloneOnEdit
settings, this
flag only has an effect if you are editing a values object that contains nested objects or arrays.
Note : This is an advanced setting
deepCloneNonFieldValuesOnEdit
- New deepCloneNonFieldValuesOnEdit value. Default value is nullCanvas.setDataPath(java.lang.String)
,
FormItem.setDataPath(java.lang.String)
,
DataSourceField.setDeepCloneOnEdit(java.lang.Boolean)
,
DataSource.setDeepCloneOnEdit(java.lang.Boolean)
public java.lang.Boolean getDeepCloneNonFieldValuesOnEdit()
FormItem.dataPath
. If this value is
not explicitly set, it defaults to the value of DataSource.deepCloneNonFieldValuesOnEdit
if there
is a dataSource, or to the value of the static deepCloneNonFieldValuesOnEdit
if there is no dataSource. Like the other deepCloneOnEdit
settings, this
flag only has an effect if you are editing a values object that contains nested objects or arrays.
Canvas.getDataPath()
,
FormItem.getDataPath()
,
DataSourceField.getDeepCloneOnEdit()
,
DataSource.getDeepCloneOnEdit()
public void setDeepCloneOnEdit(java.lang.Boolean deepCloneOnEdit)
DataSource.deepCloneOnEdit
for details of what this means. If this value is not explicitly set, it defaults to the
value of DataSource.deepCloneOnEdit
. This value can be
overridden per-field with DataSourceField.deepCloneOnEdit
.
Like the other deepCloneOnEdit
settings, this flag only has an effect
if you are editing a values object that contains nested objects or arrays, using dataPath
s.
Note : This is an advanced setting
deepCloneOnEdit
- New deepCloneOnEdit value. Default value is nullCanvas.setDataPath(java.lang.String)
,
FormItem.setDataPath(java.lang.String)
,
DataSourceField.setDeepCloneOnEdit(java.lang.Boolean)
,
DataSource.setDeepCloneOnEdit(java.lang.Boolean)
public java.lang.Boolean getDeepCloneOnEdit()
DataSource.deepCloneOnEdit
for details of what this means. If this value is not explicitly set, it defaults to the
value of DataSource.deepCloneOnEdit
. This value can be
overridden per-field with DataSourceField.deepCloneOnEdit
.
Like the other deepCloneOnEdit
settings, this flag only has an effect
if you are editing a values object that contains nested objects or arrays, using dataPath
s.
Canvas.getDataPath()
,
FormItem.getDataPath()
,
DataSourceField.getDeepCloneOnEdit()
,
DataSource.getDeepCloneOnEdit()
public void setDisableValidation(java.lang.Boolean disableValidation)
Note : This is an advanced setting
disableValidation
- New disableValidation value. Default value is nullDynamicForm.saveData()
,
DynamicForm.submit()
,
Validation overview and related methods
public java.lang.Boolean getDisableValidation()
DynamicForm.saveData()
,
DynamicForm.submit()
,
Validation overview and related methods
public void setFetchOperation(java.lang.String fetchOperation)
operationId
to use when performing fetch operations.fetchOperation
- New fetchOperation value. Default value is nullOperations overview and related methods
public java.lang.String getFetchOperation()
operationId
to use when performing fetch operations.Operations overview and related methods
public void setOperator(OperatorId operator) throws java.lang.IllegalStateException
getValuesAsCriteria()
is called?operator
- New operator value. Default value is "and"java.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic OperatorId getOperator()
getValuesAsCriteria()
is called?public void setRemoveOperation(java.lang.String removeOperation)
operationId
to use when performing remove operations.removeOperation
- New removeOperation value. Default value is nullOperations overview and related methods
public java.lang.String getRemoveOperation()
operationId
to use when performing remove operations.Operations overview and related methods
public void setSaveOperationType(DSOperationType saveOperationType)
DSOperationType
to be performed when DynamicForm.saveData()
is called. This property is automatically
set on a call to DynamicForm.editRecord()
or DynamicForm.editNewRecord()
, or may be set directly via
DynamicForm.setSaveOperationType()
. If
saveOperationType
is unset, the form will heuristically determine whether an "add" or "update" operation is
intended based on whether the primaryKey field is present and editable.
If this method is called after the component has been drawn/initialized:
Setter for the default DSOperationType
when DynamicForm.saveData()
is called. Note that this property can also be set by calling DynamicForm.editRecord()
or DynamicForm.editNewRecord()
saveOperationType
- Operation type to use as a default. Valid values are "add"
or "update"
. Default value is nullpublic DSOperationType getSaveOperationType()
DSOperationType
to be performed when DynamicForm.saveData()
is called. This property is automatically
set on a call to DynamicForm.editRecord()
or DynamicForm.editNewRecord()
, or may be set directly via
DynamicForm.setSaveOperationType()
. If
saveOperationType
is unset, the form will heuristically determine whether an "add" or "update" operation is
intended based on whether the primaryKey field is present and editable.
DSOperationType
to be performed when DynamicForm.saveData()
is called. Valid options are
"add"
or "update"
. If a DSRequest
configuration object is
passed in containing an explicit operationType this will be returned. Otherwise DynamicForm.saveOperationType
will be returned. This
attribute is automatically set via calls to data binding methods such as DynamicForm.editNewRecord()
, or it may be set explicitly.
If no explicit saveOperationType is specified for this form, the system will look at the current values for the
form. If the form has no value for the primaryKey field
,
or that field is editable and has been modified we assume an add operation, otherwise an update. If the form is a member
of a ValuesManager
, the primary key field value will be derived from the
valuesManager's values object. Default value is null
public void setSuppressValidationErrorCallback(java.lang.Boolean suppressValidationErrorCallback)
saveData()
on a form or valuesManager, by
default if the server returns an error code, any callback passed into saveData() will not be fired. If the error code
returned by the server indicates a validation error, it will be displayed to the user by updating the form items to show
the error messages, and firing any specified hiddenValidationErrors handler, otherwise the standard RPCManager error
handling logic would be invoked. Developers who want to handle errors themselves can override this default by
specifying dsRequest.willHandleError
on the DSRequest. In
this case the callback passed in will be fired even if the server returns an error status code.
If
suppressValidationErrorCallback
is set to true, if a save attempt returns a validation error code,
the user-specified callback will not be fired even if willHandleError:true
was specified on the
dsRequest - though for other error codes, the callback would be fired if willHandleError is specified on the
request. Note that this is the historical behavior for SmartGWT builds 4.0 and earlier
Note : This is an advanced setting
suppressValidationErrorCallback
- New suppressValidationErrorCallback value. Default value is falsepublic java.lang.Boolean getSuppressValidationErrorCallback()
saveData()
on a form or valuesManager, by
default if the server returns an error code, any callback passed into saveData() will not be fired. If the error code
returned by the server indicates a validation error, it will be displayed to the user by updating the form items to show
the error messages, and firing any specified hiddenValidationErrors handler, otherwise the standard RPCManager error
handling logic would be invoked. Developers who want to handle errors themselves can override this default by
specifying dsRequest.willHandleError
on the DSRequest. In
this case the callback passed in will be fired even if the server returns an error status code.
If
suppressValidationErrorCallback
is set to true, if a save attempt returns a validation error code,
the user-specified callback will not be fired even if willHandleError:true
was specified on the
dsRequest - though for other error codes, the callback would be fired if willHandleError is specified on the
request. Note that this is the historical behavior for SmartGWT builds 4.0 and earlier
public void setUpdateOperation(java.lang.String updateOperation)
operationId
to use when performing update operations.updateOperation
- New updateOperation value. Default value is nullOperations overview and related methods
public java.lang.String getUpdateOperation()
operationId
to use when performing update operations.Operations overview and related methods
public void addMember(DynamicForm member)
Canvas
can be a member of a
valuesManager, even components like Layout
or TabSet
that do not actually have any values to manage. When "valueless" components
like these bind to a ValuesManager, it is in order to provide their own child components with a shared valuesManager so
that complex data can be displayed and edited - see DataPath
for more details. For
components like DynamicForm
and ListGrid
, which do have a set of values to manage, the component's values will
subsequently be available through this valuesManager.
Note on pre-existent values when the member component is a
DynamicForm
:
If the valuesManager has a value specified for some field, for
which the member form has an item, this value will be applied to the member form. This is true whether the item has a
value or not.
However if the member form has a value for some field, and the ValuesManager does not have a specified
value for the same field, we allow the valuesManager to pick up the value from the member form.
Caution: If
a DynamicForm without a DataSource
is passed to this method, DataBoundComponent.setDataSource()
will be called on that
form, recreating the items from copies of the item configuration stored at the time the form was created. This means
that any properties or handlers added to the items after form creation will be lost. When in doubt, set the DataSource
in the form as soon as possible.
member
- component (or ID of component) to add to this valuesManager as a member.com.smartgwt.client.widgets.form.ValuesManager#addMembers
public void cancel()
DynamicForm.cancelParamName
with the value
DynamicForm.cancelParamValue
.Note that no other form data is sent. By default the current top-level page is replaced with the reply. If you wish to ignore the server reply instead, call this method like this:
dynamicFormInstance.cancel({ignoreTimeout: true, target: null});
public void cancel(DSRequest requestProperties)
DynamicForm.cancelParamName
with the value
DynamicForm.cancelParamValue
.Note that no other form data is sent. By default the current top-level page is replaced with the reply. If you wish to ignore the server reply instead, call this method like this:
dynamicFormInstance.cancel({ignoreTimeout: true, target: null});
requestProperties
- additional properties to set on the RPCRequest that will be issuedDynamicForm.cancelEditing()
,
Submitting overview and related methods
public void clearErrors(boolean showErrors)
showErrors
- If true, clear any visible error messages.Errors overview and related methods
public void clearFieldErrors(java.lang.String fieldName, boolean show)
fieldName
- field for which errors should be clearedshow
- if true, and the field is present in one of our member forms, redraw it to clear any currently
visible validation errorsErrors overview and related methods
public void clearValue(java.lang.String fieldName)
fieldName
- Which field to set the value forpublic void clearValues()
public void editNewRecord()
DynamicForm.setSaveOperationType()
to ensure subsequent calls to saveData()
will use an add
rather than an update
operation.public void editNewRecord(java.util.Map initialValues)
DynamicForm.setSaveOperationType()
to ensure subsequent calls to saveData()
will use an add
rather than an update
operation.initialValues
- initial set of values for the editor as a map of field names to their corresponding valuesDynamicForm.saveData()
,
DataBoundComponentMethods overview and related methods
public void editNewRecord(Record initialValues)
DynamicForm.setSaveOperationType()
to ensure subsequent calls to saveData()
will use an add
rather than an update
operation.initialValues
- initial set of values for the editor as a map of field names to their corresponding valuesDynamicForm.saveData()
,
DataBoundComponentMethods overview and related methods
public void editRecord(Record record)
setValues()
. This method will also call DynamicForm.setSaveOperationType()
to ensure
subsequent calls to saveData()
will use an update
rather than an add
operation.
record
- the record to be edited as a map of field names to their corresponding valuesDynamicForm.saveData()
,
DataBoundComponentMethods overview and related methods
public void fetchData()
public void fetchData(Criteria criteria)
fetchData()
public void fetchData(Criteria criteria, DSCallback callback)
fetchData()
public void fetchData(Criteria criteria, DSCallback callback, DSRequest requestProperties)
criteria
- search criteriacallback
- callback to invoke on completionrequestProperties
- additional properties to set on the DSRequest that will be issuedDataBoundComponentMethods overview and related methods
public void filterData()
DynamicForm.fetchData()
in that a case insensitive substring
match will be performed against the criteria to retrieve the data.public void filterData(Criteria criteria)
filterData()
public void filterData(Criteria criteria, DSCallback callback)
filterData()
public void filterData(Criteria criteria, DSCallback callback, DSRequest requestProperties)
DynamicForm.fetchData()
in that a case insensitive substring
match will be performed against the criteria to retrieve the data.criteria
- search criteriacallback
- callback to invoke on completionrequestProperties
- additional properties to set on the DSRequest that will be issuedDataBoundComponentMethods overview and related methods
public java.util.Map getChangedValues()
DynamicForm.rememberValues()
last ran. Note that DynamicForm.rememberValues()
runs on dynamicForm
initialization, and with every call to DynamicForm.setValues()
so this will typically contain all values the user has explicitly edited since then.getOldValues()
public java.util.Map getErrors()
{field1:errors, field2:errors}
Errors overview and related methods
public Canvas getMemberForField(java.lang.String fieldName)
fieldName
- fieldName or dataPath to checkpublic java.util.Map getOldValues()
DynamicForm.rememberValues()
. Note that rememberValues()
is called automatically by DynamicForm.setValues()
, and on form initialization, so this
typically contains all values as they were before the user edited them.getChangedValues()
public java.util.Map getValues()
setValues()
.public AdvancedCriteria getValuesAsAdvancedCriteria()
Similar to getValuesAsCriteria()
, except the returned criteria
object is guaranteed to be an AdvancedCriteria object, even if none of the form's fields has a specified FormItem.operator
AdvancedCriteria
based on the form's current valuesCriteriaEditing overview and related methods
public AdvancedCriteria getValuesAsAdvancedCriteria(TextMatchStyle textMatchStyle)
Similar to getValuesAsCriteria()
, except the returned criteria
object is guaranteed to be an AdvancedCriteria object, even if none of the form's fields has a specified FormItem.operator
textMatchStyle
- If specified the text match style will be used to generate the appropriate operator
for per field
criteria.AdvancedCriteria
based on the form's current valuesCriteriaEditing overview and related methods
public com.google.gwt.event.shared.HandlerRegistration addAsyncValidationReplyHandler(AsyncValidationReplyHandler handler)
Notification fired when an asynchronous validation completes.
addAsyncValidationReplyHandler
in interface HasAsyncValidationReplyHandlers
handler
- the asyncValidationReply handlerHandlerRegistration
used to remove this handlerpublic com.google.gwt.event.shared.HandlerRegistration addHiddenValidationErrorsHandler(HiddenValidationErrorsHandler handler)
Method to display validation error messages for a valuesManager when there is not currently visible form item displaying
the errors. This will be called when validation fails for
- a field in a hidden or undrawn member form
- a
hidden field in a visible member form
- for databound ValuesManagers, a datasource field with specified validators,
but not associated item in any member.
Implement this to provide custom validation error handling for these
fields.
By default hidden validation errors will be logged as warnings in the developerConsole. Call HiddenValidationErrorsEvent.cancel()
from within HiddenValidationErrorsHandler.onHiddenValidationErrors(com.smartgwt.client.widgets.form.events.HiddenValidationErrorsEvent)
from this method to
suppress that behavior.
addHiddenValidationErrorsHandler
in interface HasHiddenValidationErrorsHandlers
handler
- the hiddenValidationErrors handlerHandlerRegistration
used to remove this handlerpublic java.lang.Boolean hasErrors()
Errors overview and related methods
public java.lang.Boolean hasFieldErrors(java.lang.String fieldName)
fieldName
- field to check for errorsErrors overview and related methods
public java.lang.Boolean isNewRecord()
saveOperationType
is
currently "add". See saveOperationType
.public java.lang.Boolean isPendingAsyncValidation()
ValuesManager
waiting for an asynchronous validation to complete? This method will return true
after validate()
is called on a component with
server-side validators for some field(s), until the server responds. Note that the notification method ValuesManager.asyncValidationReply()
will
be fired when validation completes.
public void itemChanged(FormItem item, java.lang.Object newValue)
item
- the FormItem where the change event occurrednewValue
- new value for the FormItempublic com.google.gwt.event.shared.HandlerRegistration addMemberSynchronizedHandler(MemberSynchronizedHandler handler)
Fires after a member component's values have been synchronized from the ValuesManager's values, upon completion of the
ValuesManager.synchronizeMember()
call.
addMemberSynchronizedHandler
in interface HasMemberSynchronizedHandlers
handler
- the memberSynchronized handlerHandlerRegistration
used to remove this handlerpublic void removeMember(DynamicForm member)
valuesManager.getValues()
, but will not be updated as the form is manipulated.member
- form (or ID of form) to remove from this valuesManagerremoveMembers(com.smartgwt.client.widgets.form.DynamicForm...)
public void removeMembers(DynamicForm... members)
members
- array of forms to removeremoveMember(com.smartgwt.client.widgets.form.DynamicForm)
public void resetValues()
DynamicForm.reset()
.public void saveData()
DataSource
this form is bound
to. If client-side validators are defined, they are executed first, and if any errors are found the save is aborted and the form will show the errors.
If client-side validation passes, a DSRequest
will be sent, exactly as though DataSource.addData()
or DataSource.updateData()
had been called with the form's values
as data. The DSRequest.operationType
will be either "update" or "add", depending
on the current DynamicForm.saveOperationType
.
On either a client-side or server-side validation failure, validation errors will be displayed in the form. Visible
items within a DynamicForm will be redrawn to display errors. Validation failure occurring on hidden items, or
DataSource fields with no associated form items may be handled via DynamicForm.hiddenValidationErrors()
or
ValuesManager.hiddenValidationErrors()
.
In the case of a validation error, the callback will not be called
by default since the form has already handled the failed save by displaying the validation errors to the user. If you
need to do something additional in this case, you can set RPCRequest.willHandleError
via the requestProperties
parameter to force your callback to be invoked.
However, first consider:
built-in modes
and DynamicForm.showErrors()
may be a better place to put
customizations. central error handling
in invoked, so consider placing
customizations there unless an unrecoverable error should be handled specially by this specific form. public void saveData(DSCallback callback)
saveData()
public void saveData(DSCallback callback, DSRequest requestProperties)
DataSource
this form is bound
to. If client-side validators are defined, they are executed first, and if any errors are found the save is aborted and the form will show the errors.
If client-side validation passes, a DSRequest
will be sent, exactly as though DataSource.addData()
or DataSource.updateData()
had been called with the form's values
as data. The DSRequest.operationType
will be either "update" or "add", depending
on the current DynamicForm.saveOperationType
.
On either a client-side or server-side validation failure, validation errors will be displayed in the form. Visible
items within a DynamicForm will be redrawn to display errors. Validation failure occurring on hidden items, or
DataSource fields with no associated form items may be handled via DynamicForm.hiddenValidationErrors()
or
ValuesManager.hiddenValidationErrors()
.
In the case of a validation error, the callback will not be called
by default since the form has already handled the failed save by displaying the validation errors to the user. If you
need to do something additional in this case, you can set RPCRequest.willHandleError
via the requestProperties
parameter to force your callback to be invoked.
However, first consider:
built-in modes
and DynamicForm.showErrors()
may be a better place to put
customizations. central error handling
in invoked, so consider placing
customizations there unless an unrecoverable error should be handled specially by this specific form. callback
- callback to invoke on completionrequestProperties
- additional properties to set on the DSRequest that will be issuedDataBoundComponentMethods overview and related methods
,
Add Examplepublic void setValues(java.util.Map values)
Values should
be provided as an Object containing the new values as properties, where each propertyName is the name of a form item
in one of the member forms, and each property value is the value to apply to
that form item via FormItem.setValue()
.
Values
with no corresponding form item may also be passed, will be tracked by the valuesManager and returned by subsequent
calls to getValues()
.
Any FormItem
for which a value is not provided will revert to its defaultValue
. To cause all FormItems to revert to
default values, pass null.
This method also calls rememberValues()
so that a subsequent later call to
resetValues()
will revert to the passed values.
values
- new set of values for this values manager.public void showFieldErrors()
ValuesManager.hiddenValidationErrors()
will be fired to allow custom handling of hidden errors.Errors overview and related methods
public void submit()
submit()
is automatically called when a SubmitItem
in a
member form is clicked, or if saveOnEnter
is set for
some member form, when the "Enter" key is pressed in a text input. Submit can also be manually called. If valuesManager.submitValues()
exists, it will be called, and
no further action will be taken.
Otherwise, saveData()
will be called to handle saving via Smart GWT databinding.
The parameters to submit()
apply only if submit()
will be calling saveData()
. If you override submit()
, you can safely ignore the parameters as Smart GWT framework code
does not pass them.
com.smartgwt.client.widgets.form.ValuesManager#submitValues
,
DataBoundComponentMethods overview and related methods
public void submit(DSCallback callback)
submit()
public void submit(DSCallback callback, DSRequest requestProperties)
submit()
is automatically called when a SubmitItem
in a
member form is clicked, or if saveOnEnter
is set for
some member form, when the "Enter" key is pressed in a text input. Submit can also be manually called. If valuesManager.submitValues()
exists, it will be called, and
no further action will be taken.
Otherwise, saveData()
will be called to handle saving via Smart GWT databinding.
The parameters to submit()
apply only if submit()
will be calling saveData()
. If you override submit()
, you can safely ignore the parameters as Smart GWT framework code
does not pass them.
callback
- callback to invoke on completion.requestProperties
- additional properties to set on the DSRequest that will be issuedcom.smartgwt.client.widgets.form.ValuesManager#submitValues
,
DataBoundComponentMethods overview and related methods
public void synchronizeMember(Canvas member)
member
- Member component to synchronizesynchronizeMembers()
,
synchronizeMembersOnDataPath(java.lang.String)
public void synchronizeMembers()
automatic synchronization
.public void synchronizeMembersOnDataPath(java.lang.String dataPath)
dataPath
, to reflect the current values held by the ValuesManager. Note,
it is not normally necessary to manually synchronize membersdataPath
- dataPath to synchronizesynchronizeMember(com.smartgwt.client.widgets.Canvas)
,
synchronizeMembers()
public java.lang.Boolean validate()
Note that if validation
errors occur for a value that is not shown in any member forms, those errors will cause a warning and ValuesManager.hiddenValidationErrors()
will be called. This can occur if:
- A datasource field has no corresponding item in any member form
- The item
in question is hidden
- The member form containing the item is hidden.
If this form has any fields which require
server-side validation (see Validator.serverCondition
) this will also be initialized. Such validation will occur asynchronously. Developers can
use isPendingAsyncValidation()
and
ValuesManager.asyncValidationReply()
to detect and respond to asynchronous validation.
DynamicForm.validate()
,
Splitting Examplepublic java.lang.Boolean valuesHaveChanged()
DynamicForm.rememberValues()
method.
rememberValues()
runs when the form is initialized and on every call to DynamicForm.setValues()
. Returns true if the values have
changed, and false otherwise.getChangedValues()
,
getOldValues()
public static ValuesManager getById(java.lang.String ID)
ID
.ID
- global ID of the ValuesManagerprotected void onInit_ValuesManager()
public void showErrors()
DynamicForm.setErrors(java.util.Map, boolean)
or
DynamicForm.validate()
.
com.smartgwt.client.widgets.form.DynamicForm#handleHiddenValidationErrors
to
display errors with no visible field.
Note: This is an override point. This method may be overridden to perform custom display of validation errors.
public void setDataSource(DataSource dataSource)
dataSource
- dataSource Default value is nullpublic DataSource getDataSource()
DSRequest
. Can be specified as either a DataSource instance or the String ID of a DataSource.
public void setValue(java.lang.String fieldName, java.lang.String value)
fieldName
- Name of the field being updatedvalue
- New value.public void setValue(java.lang.String fieldName, double value)
fieldName
- Name of the field being updatedvalue
- New value.public void setValue(java.lang.String fieldName, boolean value)
fieldName
- Name of the field being updatedvalue
- New value.public void setValue(java.lang.String fieldName, java.util.Date value)
fieldName
- Name of the field being updatedvalue
- New value.public void setValue(java.lang.String fieldName, com.google.gwt.core.client.JavaScriptObject value)
fieldName
- Name of the field being updatedvalue
- New value.public void setValue(java.lang.String fieldName, java.util.Map value)
fieldName
- Name of the field being updatedvalue
- New value.public void setValue(java.lang.String fieldName, Record value)
fieldName
- Name of the field being updatedvalue
- New value.public void setValue(java.lang.String fieldName, DataClass value)
fieldName
- Name of the field being updatedvalue
- New value.public void setValue(java.lang.String fieldName, Record[] value)
fieldName
- Name of the field being updatedvalue
- New value.public void setValue(java.lang.String fieldName, DataClass[] value)
fieldName
- Name of the field being updatedvalue
- New value.public java.lang.String getValueAsString(java.lang.String fieldName)
fieldName
- the field namepublic java.lang.Object getValue(java.lang.String fieldName)
fieldName
- the field namepublic void editSelectedData(ListGrid selectionComponent)
ListGrid
). Updates the values of this editor to match the selected record's values.
If this form has a dataSource, then saving via saveData()
will use the "update" operation type.
selectionComponent
- the ListGrid or ID of a ListGrid
whose
currently selected record(s) is/are to be editedpublic DynamicForm[] getMembers()
getMemberCanvases()
public Canvas[] getMemberCanvases()
getMembers()
public void removeMember(java.lang.String formID)
formID
- ID of the form to remove from this valuesManagerpublic void removeMember(Canvas member)
public void addMember(java.lang.String member)
Canvas
can be a member of a
valuesManager, even components like Layout
or TabSet
that do not actually have any values to manage. When "valueless" components
like these bind to a ValuesManager, it is in order to provide their own child components with a shared valuesManager so
that complex data can be displayed and edited - see DataPath
for more details. For
components like DynamicForm
and ListGrid
, which do have a set of values to manage, the component's values will
subsequently be available through this valuesManager.
Note on pre-existent values when the member component is a
DynamicForm
:
If the valuesManager has a value specified for some field, for
which the member form has an item, this value will be applied to the member form. This is true whether the item has a
value or not.
However if the member form has a value for some field, and the ValuesManager does not have a specified
value for the same field, we allow the valuesManager to pick up the value from the member form.
member
- component (or ID of component) to add to this valuesManager as a member.com.smartgwt.client.widgets.form.ValuesManager#addMembers
public void addMember(Canvas member)
public com.google.gwt.core.client.JavaScriptObject rememberValues()
public void setErrors(java.util.Map errors, boolean showErrors)
errors
- list of errors as a map with the field names as keysshowErrors
- If true redraw form to display errors now. Otherwise errors can be displayed by calling
showErrors()
Note: When the errors are shown, handleHiddenValidationErrors() will be fired for errors
on hidden fields, or with no associated formItem.public void setFieldErrors(java.lang.String fieldName, java.lang.String error, boolean showErrors)
DynamicForm.showFieldErrors(java.lang.String)
will display the errors for this field.fieldName
- field to apply the new errors toerror
- error to apply to the field in questionshowErrors
- If true this method will fall through to DynamicForm.showFieldErrors() to update the displaypublic void setFieldErrors(java.lang.String fieldName, java.lang.String[] errors, boolean showErrors)
DynamicForm.showFieldErrors(java.lang.String)
will display the errors for this field.fieldName
- field to apply the new errors toerrors
- errors to apply to the field in questionshowErrors
- If true this method will fall through to DynamicForm.showFieldErrors() to update the displaypublic java.lang.String[] getFieldErrors(java.lang.String fieldName)
fieldName
- the field namepublic FormItem getItem(java.lang.String itemID)
FormItem
from this ValuesManager. Takes a field 'name'
or DataType
,
and searches through the members of this valuesManager for an editor for that field. If found the appropriate formItem
will be returned. Note that if a dataPath is passed in, it should be the full data path for the item, including any
canvas level 'dataPath'
specified on the member form containing
this form item.
Note: Unlike the DynamicForm
class, this method will not return an item by index
itemID
- item fieldName or dataPath identifierpublic com.google.gwt.event.shared.HandlerRegistration addSubmitValuesHandler(SubmitValuesHandler handler)
Triggered when a submit()
is called on this valuesManager (or any form included in this valuesManager).
handler
- the submitValues handlerHandlerRegistration
used to remove this handlerpublic Criteria getValuesAsCriteria()
com.smartgwt.client.widgets.form.DynamicForm#getValuesAsCriteria(),criteria values
for all member forms.
As with the DynamicForm getValuesAsCriteria, this method may return
AdvancedCriteria or simple Criteria depending on whether
the com.smartgwt.client.widgets.form.ValuesManager#setOperator,operator
is set to "or"
rather than "and"
, and whether any member
forms return AdvancedCriteria.
Note that developers can also use DataSource.combineCriteria(com.smartgwt.client.data.Criteria, com.smartgwt.client.data.Criteria)
to combine
sub-criteria from various sources, including member forms of a ValuesManager, into
a combined criteria object.
public Record getValuesAsRecord()