cancel
Showing results for 
Search instead for 
Did you mean: 

setComponent Not Working

Former Member
0 Kudos

I am trying to a component on ComponentContainer but just cant get it to work...

The following code works well with no errors but I can only see the two buttons in the display and not the ComponentContainer

Please help.

Code:

sap.ui.commons.layout.HorizontalLayout.extend("customcontrols.MyContainer", {

    metadata : {

        properties : {

            "value" : "string"

        },

        aggregations: {

        "_btn" : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},

        "_btn2" : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},

        "_sourceComponent": {type : "sap.ui.core.ComponentContainer", multiple : false, visibility: "hidden"}

        },

        events: {

            "search" : {}

        }

    },

    init: function() {

    this.setAggregation("_btn", new sap.ui.commons.Button({

            text: "Search",

            press: function(){

              //that.fireSearch();

            }

          }));

  

    this.setAggregation("_btn2", new sap.ui.commons.Button({

            text: "Search",

            press: function(){

            //  that.fireSearch();

            }

          }));

  

    this.setAggregation("_sourceComponent", new sap.ui.core.ComponentContainer({

  id : "id", // sap.ui.core.ID

  name : undefined, // string

  url : undefined, // sap.ui.core.URI

  settings : undefined, // object

  propagateModel : false, // boolean

  width : undefined, // sap.ui.core.CSSSize

  height : undefined, // sap.ui.core.CSSSize

  tooltip : undefined, // sap.ui.core.TooltipBase

  customData : [ new sap.ui.core.CustomData({

  id : "id1", // sap.ui.core.ID

  key : undefined, // string

  value : undefined, // any

  writeToDom : false, // boolean, since 1.9.0

  tooltip : undefined, // sap.ui.core.TooltipBase

  customData : []

  // sap.ui.core.CustomData

  }) ], // sap.ui.core.CustomData

  //component : undefined

  // sap.ui.core.UIComponent

  }));

  

    var oButton = new sap.ui.commons.Button({

            text: "Amjad",

            press: function(){

              //that.fireSearch();

            }

          });

  

    var _sourceComponent = this.getAggregation("_sourceComponent");

    _sourceComponent.setComponent(oButton);

  

    },

    setValue: function(sValue){

        this.setProperty("value", sValue, true);

        this.getAggregation("_tf").setValue(sValue);

        return this;

    },

   

    renderer : function(oRm, oControl) {

        oRm.write("<div");

        oRm.writeControlData(oControl);

        oRm.addClass("mySearchField");

        oRm.writeClasses();

        oRm.write(">");

        oRm.renderControl(oControl.getAggregation("_btn2"));       

        oRm.renderControl(oControl.getAggregation("_btn2"));

        oRm.renderControl(oControl.getAggregation("_sourceComponent"));

        oRm.write("</div>");

    }

});

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

No body?

Former Member
0 Kudos

I am trying to set* a component