ResourceBundle.prototype._enhance should be a public method
OpenUI5 version: 1.40.6
Browser/version (+device/version): API Issue
Steps to reproduce the problem: jquery.sap.resource includes a private method called _enhance that allows you to collect several resource bundles into a cascading group, which is a very handy feature. However, the method is marked as private in the JSDoc, and the name reinforces that notion. I cannot find a public supported way to access this behavior, so I'd appreciate it if you could make this public and continue to support it.
Does sap.ui.model.resource.ResourceModel#enhance not have the behavior you are talking about?
ResourceModel does, but unless I'm misreading the documentation it doesn't appear that I can pass in a ResourceModel anywhere that is expecting a ResourceBundle. In my particular case I want to create instances of Icon, passing in the enhanced bundle as the value of the iconInfo.resourceBundle parameter. If I'm wrong about how ResourceModel works then I might be able to use it.
Looking at ResourceModel a little more closely I see that I could do the following, but it seems like a hack:
- Create a ResourceModel with the base ResourceBundle
- Enhance the ResourceModel with additional ResourceBundles
- Call ResourceModel.getResourceBundle to extract the enhanced Bundle
- Throw away the ResourceModel.
Something like this?
// enhance model
var oModel = new sap.ui.model.resource.ResourceModel({bundleUrl:"something/something.properties"});
oModel.enhance({bundleUrl:"something/somethingElse.properties"});
// access bundle
var oBundle = oModel.getResourceBundle();
var text = oBundle.getText("someKey");
I think the main reason its in a model is so you can easily bind it to your views using the special notation.
{modelName>someKey}
I can see that having the ability to create a model from a set of ResourceBundles might be useful, but I don't think I can use it in my case, since the IconPool code doesn't seem to have a way to bind a model for the icon text. If I'm wrong about that I'll just do that and my problem will have gone away.
When I said "throw it away" I mean that I have no use for the Model other than as a mechanism to call an otherwise private method on the contained resource bundles. Once I extract the enhanced bundle I will be destroying the Model, assuming that doesn't recursively destroy the contained ResourceBundles.
In any case, it just seems simpler to expose the method on ResourceBundle since it's already there and does exactly what I want it to do. That way the ResourceModel wouldn't have to call a private method on another class either.
As far as I know, it's the norm to access a bundle via resource models.
For example, if I needed a particular piece of translatable text within one of the controller functions, I'd need to use something like
var oBundle = this.getView().getModel("i18n").getResourceBundle();
var text = oBundle.getText("someKey");
Anyway seems like you have solved your problem :)
Hi @RalphMarshall ,
Do we have to consider your question about exposing the method on ResourceBundle as still open?
Kind Regards, Diana, SAPUI5 Dispatcher
No you can feel free to close it.
Sent from my Apple ][
On Thu, Dec 1, 2016 at 4:14 AM -0500, "DMihaylova" <[email protected]mailto:[email protected]> wrote:
Hi @RalphMarshallhttps://github.com/RalphMarshall ,
Do we have to consider your question about exposing the method on ResourceBundle as still open?
Kind Regards, Diana, SAPUI5 Dispatcher
You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/SAP/openui5/issues/1156#issuecomment-264120186, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIt1DecD6RCs7-ceTUwxAlIyinnA1uc9ks5rDo_ZgaJpZM4KC1qT.