on 04-16-2016 4:04 AM
Hi Expert.
I am trying to complete "Building SAP Fiori-like UIs with SAPUI5" exercise 3 in JS view.
I have problem in calling statusText function of util.Formatter.js in my Detail.view.js.
The original exercise is in xml view.
Below is my codes..
Formatter.js
jQuery.sap.declare("myFioriApp.util.Formatter");
myFioriApp.util.Formatter = {
statusText : function(value) {
var bundle = this.getModel("i18n").getResourceBundle();
return bundle.getText("StatusText" + value, "?")
}
}
Detail.view.js
sap.ui.jsview("myFioriApp.Views.Detail", {
getControllerName : function() {
return "myFioriApp.Views.Detail";
},
createContent : function(oController) {
var oHeader = new sap.m.ObjectHeader({
firstStatus: new sap.m.ObjectStatus(
{text:{
formatter: function(s){
return myFioriApp.util.Formatter.statusText(s)
}}})}
}
Function statusText() did get called but (this.) does not have an instance of text control therefor it fails to call getModel() function of it's aggregate.
Thanks in advance for your reply.
Currently my workaround is to pass the text's object from the view to Formatter.js but I believe there must be a better answer out there.
Formatter.js
jQuery.sap.declare("myFioriApp.utility.Formatter");
myFioriApp.utility.Formatter = {
statusText: function(textObject,value){
var bundle = textObject.getModel("i18n").getResourceBundle();
return bundle.getText("StatusText" + value, "?")
}}
Detail.view.js
sap.ui.jsview("myFioriApp.Views.Detail", {
getControllerName : function() {
return "myFioriApp.Views.Detail";
}},
createContent : function(oController) {
var oHeader = new sap.m.ObjectHeader({
firstStatus: new sap.m.ObjectStatus({text:
{path: "LifecycleStatus",
formatter: function(s){
return myFoioriApp.utility.Formatter.statusText(this, s)
}
}
})})
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Edwin, Please load the dependency. jQuery.sap.require("myFioriApp.util.Formatter"); Thanks, Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Edwin
{
text: {
path: '?',
formatter: function(s){
return myFioriApp.util.Formatter.statusText(s)
}
}
}
path is missing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
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.