cancel
Showing results for 
Search instead for 
Did you mean: 

How to share a ResourceModel In a UIComponent?

Former Member
0 Kudos

Hi All,

In my sap.ui.core.UIComponent.init I have the following:

var oModel = new sap.ui.model.resource.ResourceModel({bundleName : "path/bundle", bundleLocale:sap.m.getLocale().sLocaleId});

this.setModel(oModel , "i18n");

The UIComponent creates a sap.ui.view.

The translation in the view works fine, but not for fragments/dialogs that are created from the view.

I thought of 2 solutions:

1. For each fragments/dialogs that are created, set the view model to them.

2. sap.ui.getCore().setModel(oModel , "i18n");

What is the best approach? Do you have another solution for this issue?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

maximilian_lenkeit
Participant
0 Kudos

If you add your dialogs to the dependents aggregation of a the view, they will inherit the models. That's the preferred way. See this link:

SAPUI5 SDK - Demo Kit

- Max

Former Member
0 Kudos

Thanks for you answer max.

Do you know of a way to solve it for dialog? (not fragment)

maximilian_lenkeit
Participant
0 Kudos

Same thing, just add your dialog to the dependents aggregation. It doesn't matter whether the dialog is created directly or through a fragment.

- Max

Former Member
0 Kudos

Thank!

It fixed the problem.

Answers (0)