on 2014 Aug 22 12:44 PM
Hi,
I'm building an App using the Component approach which is great. But now I'm facing the problem that I can't access my parent (or any other) component from within a component. I came to know that there is a method getComponent on the core but
sap.ui.getCore().getComponent("myComponentId")
does not give me anything.
sap.ui.getCore().getRootComponent()
doesn't return anything either.
This is the code I use to create the component:
new sap.ui.core.ComponentContainer("componentId", {
height : "100%",
width : "100%",
name : "com.component.my.nice",
propagateModel: true
});
The whole thing is running in a sap.m.Shell + sap.m.SplitApp. The SplitApp is created as the root component of the Shell in my index.html like this:
new sap.m.Shell("Shell", {
app: new sap.ui.core.ComponentContainer("RootContainer", {
height : "100%",
width : "100%",
name : "com.component.root",
displayBlock : "true",
mode : "HideMode"
})
}).placeAt("content");
What am I doing wrong and why can't I query my components? How can I access the general component registry?
Cheers
Christian
Request clarification before answering.
To avoid this problem I added this method to all of my controllers:
getComponent: function () {
var sComponentId = sap.ui.core.Component.getOwnerIdFor(this.getView());
return sap.ui.component(sComponentId);
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You normally dont need to put it inside the controller. You normally should be able to use :
this.getOwnerComponent() to the component.
Alex
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.