Constructor
new module:br/presenter/property/EditableProperty(vValue)
EditableProperty instance.
Extends:
Parameters:
| Name | Type | Description |
|---|---|---|
vValue |
Object | (optional) The default value for this property. |
- Implements:
- module:br/presenter/validator/ValidationResultListener
- Source:
Extends
Methods
-
addFormatter(oFormatter, mConfig)
-
Add a
module:br/presenter/formatter/Formatterthat will be applied to the property before it's rendered to screen.Any number of formatters can be added to a property, and will be applied in the same order in which the formatters were added.
Parameters:
Name Type Description oFormattermodule:br/presenter/formatter/Formatter The formatter being added. mConfigObject (optional) Any additional configuration for the formatter. - Inherited From:
- Source:
-
addParser(oParser, mConfig)
-
Adds a
module:br/presenter/parser/Parserthat will be run each time the user enters a new value.Parsers allow user input to be normalized prior to validation. For example, the user may be allowed to enter '1M' into an amount field, and a parser might convert this to '1000000' before it is validated by a numeric validator.
Any number of parsers can be added to an editable property, and will be applied in the same way that production rules are applied in production rule systems:
- The parsers will be iterated one by one in the same order in which they were added.
- If any parser is able to produce a new value from the input, then this value becomes the current value and the process restarts at step 1.
- Once a clean run through all the parsers is achieved (with none of them available to produce new input) the parsing phase is complete.
By configuring a number of simple parsers in the same way as production rules are used, complex input handling can be supported.
Parameters:
Name Type Description oParsermodule:br/presenter/parser/Parser the module:br/presenter/parser/Parserbeing added.mConfigObject (optional) Any additional configuration for the parser. -
addValidationCompleteListener(fCallback, bNotifyImmediately)
-
A convenience method that allows validation complete listeners to be added for objects that do not themselves implement
module:br/presenter/property/PropertyListener.Listeners added using
addValidationCompleteListener()will only be notified whenmodule:br/presenter/property/PropertyListener#onValidationCompletefires, and will not be notified if any of the othermodule:br/presenter/property/PropertyListenercall-backs fire. The advantage to using this method is that objects can choose to listen to call-back events on multiple properties.Parameters:
Name Type Description fCallbackfunction The call-back that will be invoked each time validation is complete. bNotifyImmediatelyboolean (optional) Whether to invoke the listener immediately for the current value. -
addValidationErrorListener(fCallback, bNotifyImmediately)
-
A convenience method that allows validation error listeners to be added for objects that do not themselves implement
module:br/presenter/property/PropertyListener.Listeners added using
addValidationErrorListener()will only be notified whenmodule:br/presenter/property/PropertyListener#onValidationErrorfires, and will not be notified if any of the othermodule:br/presenter/property/PropertyListenercall-backs fire. The advantage to using this method is that objects can choose to listen to call-back events on multiple properties.The invoked method will be passed two arguments:
vPropertyValue— The current value of the property.sErrorMessage— The failure message.
Parameters:
Name Type Description fCallbackfunction The call-back that will be invoked each time there is a validation error. bNotifyImmediatelyboolean (optional) Whether to invoke the listener immediately for the current value. -
addValidationSuccessListener(fCallback, bNotifyImmediately)
-
A convenience method that allows validation success listeners to be added for objects that do not themselves implement
module:br/presenter/property/PropertyListener.Listeners added using
addValidationSuccessListener()will only be notified whenmodule:br/presenter/property/PropertyListener#onValidationSuccessfires, and will not be notified if any of the othermodule:br/presenter/property/PropertyListenercall-backs fire. The advantage to using this method is that objects can choose to listen to call-back events on multiple properties.Parameters:
Name Type Description fCallbackfunction The call-back that will be invoked each time validation is successful. bNotifyImmediatelyboolean (optional) Whether to invoke the listener immediately for the current value. -
addValidator(oValidator, mConfig, mValidatorInfo)
-
Adds a
module:br/presenter/validator/Validatorthat will be run each time the user enters a new value.Validators allow users to be immediately informed when any of their input is invalid. The
module:br/presenter/node/Field,module:br/presenter/node/SelectionFieldandmodule:br/presenter/node/MultiSelectionFieldclasses all listen to the validation call-backs onmodule:br/presenter/property/PropertyListenerand maintainhasErrorandfailureMessageproperties that can be displayed within the view.Parameters:
Name Type Description oValidatormodule:br/presenter/validator/Validator the module:br/presenter/validator/Validatorbeing added.mConfigObject (optional) Any additional configuration for the validator. mValidatorInfoObject (optional) Information about the validator gets written here. -
forceValidation()
-
Force the property to be re-validated.
This method is useful for code that wishes to perform cross-property validation — it is used by the
module:br/presenter/validator/CrossValidationPropertyBinderclass for example. -
getFormattedValue()
-
Returns the formatted value for this property if any formatters have been attached, otherwise returns the raw property value.
-
getPath()
-
Returns the path that would be required to bind this property from the view.
This method is used internally, but might also be useful in allowing the dynamic construction of views for arbitrary presentation models.
- Inherited From:
- Source:
-
getRenderedValue()
-
Returns the rendered value after applying any active formatters, otherwise returns the raw property value.
-
getValue()
-
Returns the unformatted value for this property.
- Inherited From:
- Source:
-
hasValidationError()
-
This method provides a synchronous way of checking the validation state.
-
removeAllListeners()
-
Remove all previously added
module:br/presenter/property/PropertyListenerinstances. -
removeListener(oListener)
-
Remove a previously added
module:br/presenter/property/PropertyListener.Parameters:
Name Type Description oListenermodule:br/presenter/property/PropertyListener The listener being removed. -
removeParser(parser) → {boolean}
-
Removes
module:br/presenter/parser/Parserfrom parsers array.Parameters:
Name Type Description parserObject The parser to remove. Returns:
- true if any validator was removed- Type
- boolean
-
removeValidator(mValidatorInfo) → {boolean}
-
Removes
module:br/presenter/validator/Validatorfrom validators array.Parameters:
Name Type Description mValidatorInfoObject The validator information returned by addValidator() Returns:
- true if any validator was removed- Type
- boolean
-
setUserEnteredValue(vUserEnteredValue)
-
Accepts a user entered value that may need to be parsed before calling
#setValue.Parameters:
Name Type Description vUserEnteredValueObject The unparsed value to set. -
setValue(vValue)
-
Sets the unformatted value for this property and notifies listeners of the change.
This method is the same as
module:br/presenter/property/WritableProperty#setValue, except that validation will also be performed.Parameters:
Name Type Description vValueVariant The value to set. - Overrides:
- Source:
- See:
-
- br.presenter.property.WritableProperty#setValue