cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 Message Manager

Former Member
0 Kudos

Hi,

I am trying out the SAPUI5 messsage manager and based on the documentation by SAP, Step 11: Validation Using the Message Manager, I can simply just create a control and register that object with the message manager and supposedly it will render an error message for that control if there is some validation or parse error.

I tested it out and yes, the error is captured by the message manager, but no error message or label is render for the control when I focus out of the control or press enter.

Anything else did I miss out?

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

It seems the sap.m.Input Control support receiving validation messages and the sap.ui.commons.TextField doesn´t support it.

Please check my example: JS Bin - Collaborative JavaScript Debugging

Best regards

Former Member
0 Kudos

Well, that point was bothering me, so I looked into it, and here we are.

As of today, it seems that the version of sap-ui-core.js is different whether you load it from your SAP HCP environment (using "../resources/sap-ui-core.js") or loading it from https://openui5.hana.ondemand.com/resources/sap-ui-core.js.

The version "embedded" in the SAP HCP environment works as intended in the tutorial, but if you download the code as a zip from the Explored app, then sap-ui-core.js is loaded from https://openui5.hana.ondemand.com, which seems to be not OK.

I might be wrong about this, and I would gladly stand corrected, but I am afraid that the version from openui5.hana.ondemand.com is newer than the one embedded in SAP HCP, thus possibly introducing a regression if this version is deployed in productive use.

edit: I checked this morning the version in the js files:

- https://openui5.hana.ondemand.com/resources/sap-ui-core.js, is in version 1.32.5 (buildtime: "20151102-1510"),

- https://sapui5.hana.ondemand.com/resources/sap-ui-core.js and ../resources/sap-ui-core.js, are the same, version 1.30.9 (buildtime: "20151005-1141").

SAPWebIDE let us use sap-ui-core.js version 1.32.4, which is buggy in regards of this tutorial...

saivellanki
Active Contributor
0 Kudos

Beck,


I would see that you have to add sap.ui.getCore().attachValidationError(function(oEvent){}) manually for changing the value state.

Please check the sample here, try to enter more than five characters in the text field: JS Bin - Collaborative JavaScript Debugging


Regards,

Sai Vellanki.

Former Member
0 Kudos

that seems like the case. apparently I think that the message manager only keeps track of message but does not help to display it automatically like what they show in the demo SAPUI5 Explored .

but anyway, thanks guys. will go with manually showing the error message.

saivellanki
Active Contributor
0 Kudos

Yes, you're right! Message Manager logs the messages that are encountered.


Regards,

Sai Vellanki.

saivellanki
Active Contributor
0 Kudos

Hi Beck,

Did you mention the message in valueStateText property? Just for a reference, check this example from explored: SAPUI5 Explored

Regards,

Sai Vellanki.

Former Member
0 Kudos

I am looking at the example from the link provided. So does that means that even when I am using message manager, I still have to attachValidationError and attachParseError. And manually code the part to highlight the control using setValueState().

So nothing is automatically done by the message manager but just storing the error I would say?

saivellanki
Active Contributor
0 Kudos

Beck,

Apologies, I completely lost it. So, you're using a message manager.


If you want validation text need to be displayed for the control, you have to either activate the automatic message generation for controls (or) you can also create UI messages and manually add them to the message manager. Check this link for more info: SAPUI5 SDK - Demo Kit


And also in the API, I see that sap.ui.getCore().getMessageManager is available from 1.33.0, not sure why it is documented like that: JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.core.Core


Regards,

Sai Vellanki.

Former Member
0 Kudos

Yes. I have already register my object to the messagemanager(). using getMessageModel() I am able to get all the error messages that are populated due to validation or parse error.

But the UI side just aren't working like how the SAP demo example is showing where it automatically trigger a red border and show an error message when the control is in focus.

saivellanki
Active Contributor
0 Kudos

Beck,

I hope you're using Input control.

After entering the value, did you remove focus from the input base like using a tab button / clicking some where else on screen? And also are you entering invalid conditions for the input base? Even doing all the above, still it is not working?


Let me try this myself and come back to you.


Regards,

Sai Vellanki.

Former Member
0 Kudos

Yes. I am using a textfield with data binding and model type of float. typing abc should produce parse error which is captured by the message manager after I press enter or focus out.

but error message is not displayed for the control when I focus back in

Former Member
0 Kudos

Hi,

Check the css weather its change and also check DOM element when your focusing again

Former Member
0 Kudos

no css changes.