on 04-06-2016 4:32 PM
I am following the SAP's guidelines and updated the manifest.json with my resource bundle.
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "sap.ui.demo.wt.i18n.i18n"
}
}
}
This is not working in Fragment.
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns:commons="sap.ui.commons"
xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:form="sap.ui.layout.form"
xmlns:l="sap.ui.layout" xmlns:sap.ui.core="sap.ui.core">
<Dialog
title="{i18n>titleFragTitle}" contentWidth="50%">
<content>
can u show me the code how you initialize the fragment?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In my controller, I have the fragment called
this._oPopover = sap.ui.xmlfragment("myapp.fragment.myfragment", this);
this._oPopover.openBy(evt.getSource());
SAP is asking to use manifest.json for calling the resource bundle i18n.properties. Should we continue with that option or we need to use Component.js
Also, I can get the translations from properties in the main View but in the fragment they are not loading.
What do you mean with slow? Normally this should not affect speed. Add dependent adds the Dialog to the dependent aggregation of your view. Then it will get access to the models on the view and also be destroyed when the view gets destroyed.
Hi Suhaas,
Manifest.json is the app descriptor file. Here we specify only the configurations and paths. To be able to use the resource model (and for that matter any other model also) you need to create it and associate the same with either component or view or fragment.
Sample is -
In component controller -
// set the i18n model
this.setModel(models.createResourceModel(bundleName), "i18n");
in models.js file create a function as -
createResourceModel: function(sBundleName) {
var oResourceModel = new ResourceModel({
"bundleName": sBundleName
});
return oResourceModel;
},
Then you can reference the same and it will work.
BR.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ankit
Iam not doing the above becuase, SAP says below and I am in SAPUI5 verison 1.32
Automatic model instantiation is only available as of SAPUI5 version 1.30. If you are using an older version, you can manually instantiate the resource bundle and other models of the app in the
init
method of the
Component.js
file as we did in Step 9: Component Configuration.
Also, when I try below code in my controller instead of Component.js , it did not work.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.