Skip to Content
avatar image
Former Member

getComponent in SAPUI5 Application in Fiori

Hello Community,

I am facing a strange issue and I think I am stucked.

I open a MessageBox.confirm with a close method.

I want to get a specific id from the source view: "plugin_table"

In the main controller it is easy, this.getView().byId("plugin_table").

But in the method of the MessageBox, this is related to the confirmbox.

I get the value via the sap core:

sap.ui.getCore().getComponent("__component0").byId("AdminPage").byId("plugin_table")

This works in my trial station, but if i publish it to Fiori Launchpad the component will be renamed and the access doesn't work anymore.

I tried everything, either to set my own component id, but no success.

And I don't get the component in a flexible way, I always need to know the component id.

I thought with getRootComponent() I will get it, but it is always undefined.

How can I handle this, I am facing this issue at serveral places.

Please help,

BR

Marcel

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Sep 26, 2017 at 01:26 PM

    why you want it?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 26, 2017 at 01:54 PM

    Maybe my logic is wrong, but the idea is.

    A User klicks on a delete Button. With the confirm Message Box I want to ask if the user eally wants to delete.

    And in the close method I check for the answer, if the user click close, do nothing if the user click "OK" then I will delete the selected records, therefore I need to know with:

    sap.ui.getCore().byId("plugin_table").getSelectedItem()

    Which record I need to delete.

    I think thats a normal usecase. What other possibilities I have?

    BR

    Marcel

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 26, 2017 at 04:10 PM

    use eventbus to fire event to inform the controller to delete the record.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 26, 2017 at 07:18 PM

    Thanks,

    that was a perfect suggestion.

    This eventbus function is cool and useful for many other usecases.

    BR

    Marcel

    Add comment
    10|10000 characters needed characters exceeded