How to get and modify/replace/remove an event listener
<p>I am extending a SAP standard Fiori App. They have one method for creating a <a href="https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.ViewSettingsDialog.html" rel="nofollow"><code>sap.m.ViewSettingsDialog</code></a>. Now I am adding my own <a href="https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.ViewSettingsItem.html" rel="nofollow"><code>sap.m.ViewSettingsItem</code></a> containing some <a href="https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.ViewSettingsFilterItem.html" rel="nofollow"><code>sap.m.ViewSettingsFilterItem</code></a>s.</p>

<p>Now I want to modify/replace/remove the Listener on the event <code>confirm</code>, because I can not save the values from the bound ODataModel onto the CusomObject the way SAP does.</p>

<p>My attempt was to enhance their confirm method. I searched SCN, Stackoverflow and the SAPUI5 API for a getter for eventhndlers, I did not found anything. So how can I get that object?</p>

<p>For further understanding of my problem underneath it:</p>

<p><strong>Their confirm method:</strong></p>

<pre><code>              confirm: function (oEvent) {
            //reset the buffered filter arrays
            self.filterValueArray.length = 0;              
            var p = oEvent.getParameters(),
                aFilters,
                oCallback;

            for (var i = 0 ; i &lt; p.filterItems.length; i++) {
                if (p.filterItems[i] instanceof sap.m.ViewSettingsCustomItem) { // custom control filter
                    oCallback = p.filterItems[i].getCustomData()[0].getValue();
                    aFilters = oCallback.apply(this, [p.filterItems[i].getCustomControl()]);
                    if (aFilters) {
                        // the filter could be an array of filters or a single filter so we transform it to an array
                        if (!Array.isArray(aFilters)) {
                            aFilters = [aFilters];
                        }
                        self.filterValueArray = self. filterValueArray.concat(aFilters);
                    }
                } else if (p.filterItems[i] instanceof sap.m.ViewSettingsItem) { // standard filter
                    aFilters = p.filterItems[i].getCustomData()[0].getValue();
                    if (aFilters) {
                        // the filter could be an array of filters or a single filter so we transform it to an array
                        if (!Array.isArray(aFilters)) {
                            aFilters = [aFilters];
                        }
                        self.filterValueArray = self.filterValueArray.concat(aFilters);
                    }
                }
            }

            // apply filters to the table binding
            self._updateList(self.getList().getBinding("items"));

            // update info toolbar
            self.getView().byId("infoBarToolbar").setVisible((self.filterValueArray.length &gt; 0) ? true: false);
            self.getView().byId("infoBarFilter").setText((self.filterValueArray.length &gt; 0) ? p.filterString: "");  

            // save expiry filter state for the "cancel" action
            self._setExpiryFilterState();                       
        }
</code></pre>

<p><strong>My added Filter</strong></p>

<pre><code>var oBindingInfo = {
            path: "/PathToTheKeyValuePairs",
            template: new sap.m.ViewSettingsItem({
                key: "{Key}",
                text: "{Value}",
                customData: new sap.ui.core.CustomData({
                    key: "callback",
                    value: function(oControl) {
                        debugger; //getting the data and creating filter here
                    }

                 //That would be the SAP Solution Sap does with hardcoded Filter

                    // key: "filter",
                    // value: new sap.ui.model.Filter("TargetAttribute", sap.ui.model.FilterOperator.EQ, "{Key}") //fixme It takes the string and no binding info
                })
            })
        };

        var oMyCustomFilter = new sap.m.ViewSettingsFilterItem({
            key: "myCustomFilter",
            text: self.resourceBundle.getText("myFilterName"),
        });


        oMyCustomFilter.bindAggregation("items", oBindingInfo);
        this.filterDialog.addFilterItem(oMyCustomFilter);
</code></pre>