Addressing event handlers in XML: `.myHandler` or `myHandler`?

Viewed 54

I've paid attention, in some UI5-samples, I can see press=".onCloseDialog", in another: press="onCloseDialog".

I mean, in some cases, the name of controller's method in XML-template is written with the leading dot and sometimes without. Is it a matter of a taste?

1 Answers

Is it a matter of a taste?

No. According to Addressing the Event Handler:

  • Names starting with a dot ('.') are always assumed to represent a method in the controller. [...] These names are relative to the view/controller. For example, press=".myLocalHandler" is resolved by attachPress(oController["myLocalHandler"], oController);.
  • Names without dot are interpreted as a relative name; if nothing is found, they are interpreted as an absolute name. This variant is only supported for backward compatibility.

--> See also the message from the commit 226bc69.

Use always press=".onCloseDialog" when referring to the controller method.

Related