I have an OpenUI5 form consisting of several Inputcontrols. These Inputcontrols are model bound using OpenUI5 DataBinding, as described in the documentation . For instance:
new sap.m.Input({ value: { path: "/Position/Bezeichnung", type: new sap.ui.model.type.String(null, { minLength: 1, maxLength: 128 }) } })
As in the example above, I use string length restrictions. When the User changes the value of the input, a check is activated and, in accordance with the Validationresult, one of the functions described here is called. In these functions, I set the Control's ValueState as follows:
setupValidation: function() { var oCore = sap.ui.getCore(); oCore.attachValidationError(function (oEvent) { oEvent.getParameter("element").setValueState(sap.ui.core.ValueState.Error); }); oCore.attachValidationSuccess(function (oEvent) { oEvent.getParameter("element").setValueState(sap.ui.core.ValueState.None); }); oCore.attachFormatError(function (oEvent) { oEvent.getParameter("element").setValueState(sap.ui.core.ValueState.Error); }); oCore.attachParseError(function (oEvent) { oEvent.getParameter("element").setValueState(sap.ui.core.ValueState.Error); }); },
Assume that the associated model variable is the source. I load the view, the value of the property is parsed and displayed as empty. The Validationerror / Parseerror method is called not , although the restrictions are not met. This is apparently the standard behavior of OpenUI5. Only changes to the control will be checked.
Now suppose I have a submit button and the Inputcontrol is still empty. When the user clicks the submit button, I would like to start the DataBinding check for all the children of my view. This will confirm the above entry and result in an error.
My question is: how can I initiate a data binding check for all children of my view?
There is one more question about https://stackoverflow.com/a/3129609/ where the poster sets the way to define required fields. The suggested solution is to call getValue () on the control and check the value manually. I think this is rather cumbersome, since information about the formation and limitation and logic are already present.
source share