Skip to Content
0
Apr 05, 2016 at 02:03 PM

How to provide input validation using type and message manager

342 Views

Hi All

I am trying to provide a input data validation using the data type and message manager

So in the xml view, the input field has a data type defined

<Input enabled="{localData>/fields/enabled}"
  value="{ parts: [{path: 'localData>/fields/workCenter'}], type: 'sap.ui.model.type.String', constraints : { minLength: 1, maxLength: 4 } }"
  width="50%"/>

So this should restrict the end user to enter more than 4 chars in the input. The value field is bound to local json model data

In the onInit method of the view controller, I have registered to the Message Manager using

onInit: function(){
  sap.ui.getCore().getMessageManager().registerObject(this.getView(), true);
  }

However, at runtime - when the user enters more than 4 chars and moves the focus to a different UI - the validation is not triggered.

Is there anything I am missing?

Thanks

Sandip