0
votes

I'd like to extend the sap.m.Bar control with my own class and automatically generate controls for content{Left,Right,Middle}. My problem is that I need to pass bindings from my control to some of the created content controls so that I can use the properties of my Bar control to define the text of a label created for the contentMiddle aggregation.

I could reimplement the renderer and (re)create those controls every time its rendered but that feels wrong and messy.

Is there a easy way to pass bindings to other controls or to bind properties to properties of other controls?

[edit] To clearify, I know that I can rebind the Binding information like this:

    var oNameBinding = this.getBindingInfo("displayName");
    var oLabel = new sap.m.Label();
    oLabel.bindProperty("text", oNameBinding);
    this.insertContentMiddle(oLabel);

But, while everything look correct in the SAPUI5 Diagnostics inspector, no text is rendered.

1

1 Answers

1
votes

When you set the binding on the Label there is no connection between Label and your Bar yet. After insertion Label learns his parent and binding propagates. So if you first insert then bind, it should work fine.

On the other hand, you cannot know when binding is set for your displayName without overwriting bindProperty which is not so good and actually someone can also use this property without binding. So, instead you can create and insert your label on init lifecycle function with keeping the reference and on setDisplyName function you can just set your label text.