Reputation: 13
In the current project, I have a SimpleForm on a view. Binding a JSONModel on this view, the validateValue
function is working fine on my input field. The constraints on the input field are defined as follows:
<Input value="{
path: '/carrId',
type: 'sap.ui.model.type.String',
constraints: {
// ...
}
}"/>
Changing the model to an ODataModel
doesn't fire the validateValue
and the field is not marked with red if the constraints are not matched.
The view is registered at the message manager.
Do I have to implement the validation by implementing a change
event or where is the mistake?
Upvotes: 1
Views: 1691
Reputation: 18044
Replace with the type corresponding to the EDM type of your sap.ui.model.type.String
carrId
. E.g. with sap.ui.model.odata.type.String
if it has the Type="Edm.String"
in metadata. Note that the constraints
settings are also different.
In order to actually allow transferring the user input from the UI back to the model, and thus triggering parseValue
and validateValue
automatically, the binding mode needs to be TwoWay
(The default binding mode of v2.ODataModel
is OneWay
*).
Open manifest.json
Set /sap.ui5/models/<modelName>/settings/defaultBindingMode
to "TwoWay"
:
{
"dataSource": "MyV2ODataSource",
"settings": {
"defaultBindingMode": "TwoWay",
"preliminaryContext": true
},
"preload": true
}
* See Binding Modes: One-time Binding, One-way Binding, and Two-way Binding
Upvotes: 2