Skip to Content
0

getComponent in SAPUI5 Application in Fiori

Sep 26, 2017 at 12:55 PM

62

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Jun Wu Sep 26, 2017 at 01:26 PM
0

why you want it?

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Sep 26, 2017 at 01:54 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Sep 26, 2017 at 04:10 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Sep 26, 2017 at 07:18 PM
0

Thanks,

that was a perfect suggestion.

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

BR

Marcel

Share
10 |10000 characters needed characters left characters exceeded