OddDev
OddDev

Reputation: 3734

How to interact with a Component's aggregation

I've configured an aggregation for my Component. It looks like this:

        aggregations : {
            busyDialog : {
                type: "sap.m.BusyDialog",
                multiple: false
            }
        }

So, the aggregation is called "busyDialog" and can contain objects of the type "sap.m.BusyDialog".

I'm also able to get the object with its settings via my.ui5.namespace.Component.getMetadata().getAggregations().busyDialog

However, I'm not sure what's the best way to add an item to it or access an already added control in the aggregation. Are there any methods like "addbusyDialog" or something?

Was following this: http://help.sap.com/saphelp_hanaplatform/helpdata/en/01/87ea5e2eff4166b0453b9dcc8fc64f/content.htm?fullscreen=true

Upvotes: 0

Views: 52

Answers (1)

Dez
Dez

Reputation: 91

OpenUI5 automatically generates the following methods for aggregations where multiple is false (where item is the name of the aggregation):

setItem(oItem)
getItem()
destroyItem()

And it creates these methods where multiple is true:

addItem(oItem)
insertItem(oItem, iIndex)
getItems()
indexOfItem(oItem)
removeItem(vItem) // item or index of item
removeAllItems()
destroyItems()

To answer your specific question, the best way to manipulate your busyDialog aggregation is to use these generated methods:

myComponent.setBusyDialog(oBusyDialog);
myComponent.getBusyDialog();
myComponent.destroyBusyDialog();

Source: https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.base.ManagedObject.html

Upvotes: 1

Related Questions