SAPUI5 - what does setting an array for the event handler in the XML do?

I saw in the UI5 "Explored" examples a press event with what looks to be an array:

press="[handleViewSettingsDialogFilterBarPressed, views.control.tableViewSettingsDialog]"

Example on line 25

I understand how normal press events work. What does using an array like this do? I couldn't find documentation on it, so any info on how it works or a link to where it's documented would be very helpful.

1 answer

  • answered 2017-12-29 19:47 Jonathan.Brink

    I'm not seeing a mention of this this in the JSDoc, but when populating the constructor for metadata events there is a syntactic-sugar way of specifying multiple callbacks. As you mention, we are seeing this with the "press" field:

    <Toolbar
        id="vsdFilterBar"
        active="true"
        visible="false"
        press="[handleViewSettingsDialogFilterBarPressed, views.control.tableViewSettingsDialog]">
        <Label id="vsdFilterLabel" text="?" />
    </Toolbar>
    

    In this case, we are passing a string that can be parsed into an array of strings...with each entry corresponding to a function on the associated controller.

    The framework-level function that is eventually called to attach the events is sap.ui.model.Binding. Looking at that function we can see the multiple callbacks being setup with the jQuery.each.