on 05-16-2016 1:52 PM
Hi All,
I have a reusable component which can be instantiated in other applications using
sap.ui.getCore().createComponent({
name: "sample.service",
id : "a12345",
settings:{
key: "A9320"
}
In my component.js, I want to be able to access the value of the property key inside createContent to change the view being loaded according to the value of the key.
var Component = UIComponent.extend("sample.service.Component", {
metadata : {
"manifest" : "json",
"library" : "sample.service",
properties : {
key : {type: 'string', group: 'Misc', defaultValue:null},
}
},
onBeforeRendering:function()
{
console.log(this.getKey());
// this.page = new sap.ui.view({ viewName:"sample.service.view.View2", type:sap.ui.core.mvc.ViewType.XML});
},
init : function()
{
UIComponent.prototype.init.apply(this, arguments);
var a;
},
createContent: function(){
console.log(this.getKey());
if(this.getKey() === "a123")
{
this.page = new sap.ui.view({ viewName:"sample.service.view.View1", type:sap.ui.core.mvc.ViewType.XML});
}
else
{
this.page = new sap.ui.view({ viewName:"sample.service.view.View2", type:sap.ui.core.mvc.ViewType.XML});
}
return this.page;
},
});
Although the getters and setters are defined automatically for the property, if I call this.getKey() inside createContent, it returns an empty string.
I can access the key value inside the controller of the view after the view is instantiated but not in init() or createContent().
this.getKey() returns the value in onBeforeRendering() also. Is it possible to change the view being loaded at this point?
The development toolkit mentions that a JSON object componentData can be accessed inside createContent.How do I access this object? Where are the parameters defined?
Thanks and Regards,
VIjay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.