MessageBox & MessageToast Binding Issue
OpenUI5 version: 1.22.9
OS: Microsoft Windows 7 64-bit SP1
Browser: Google Chrome 37.0.2062.120 m
What is the expected result?
A MessageBox with the title "Warning" and the body text "Self destruct sequence initiated..."
Or a MessageToast with the text "Yum toast!"
What happens instead?
A MessageBox with no title or text
Or a MessageToast with the text "{/messageToastText}"
Example Demo
P.S I've only been working with OpenUI5 for a few weeks, sorry if it is in fact my error.
Hi Lucien,
data binding is a feature which works for the value of control properties. It is not like you can everywhere use data binding instead of strings. Message*.show(...) are just static methods.
However, of course they still create controls with bindable properties and at least in case of MessageBox the bindign string is directly forwarded, so it should work. The problem here is rather that the model is set on a View and when popups are opened, they are moved out of the View to the root of the document, so the model is not available. For normal popups where you get control instances, there is a solution using the "dependents" aggregation; this is not possible here. But using sap.ui.getCore().setModel(...) to set the model globally makes the MessageBox work.
MessageToast is just a helper class, not a control. So I don't think data binding can be expected from this function. I'll leave the ticket open to get further opinions, though.
Thanks and regards Andreas
You're absolutely right, thanks for the detailed explanation!
My main concern was internationalisation where I had a resource model, and everything could be translated apart from the MessageBox and MessageToast data which would be problematic.
But now, I realise that I could make the model global or infact give the model a name like i18n as a second argument and then address it like so:
sap.ui.getCore().byId("EXAMPLE").getModel("i18n").getResourceBundle().getText("EXAMPLE");
Long winded, but it works.
I close this issue as it has been idle now for month.