cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Cant get To Run AggregationBinding Example :(

Former Member
0 Likes
587

I am trying to run this example but some how just cant

<!DOCTYPE HTML>

<html>

  <head>

  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <script src="resources/sap-ui-core.js"

  id="sap-ui-bootstrap"

  data-sap-ui-libs="sap.ui.commons"

  data-sap-ui-theme="sap_goldreflection">

  </script>

  <!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->

  <script>

  $(document).ready(function()

  {

  var data =

  {

  company:

  {

  properties: [

                 {value: "Hello"},

                 {value: true},

                 {value: 45},

                ]

  }

  }

  var oModel = sap.ui.model.json.JSONModel();

  oModel.setData(data);

  sap.ui.getCore().setModel(oModel);

  var oContainer = new sap.ui.core.ComponentContainer("oContainer", {

         name: "oContainer",

         settings: {text: "Hello World 2"}

     });

  alert("...");

  oContainer.bindAggregation("content", "/company/properties", function(sId, oContext)

  {

    var value = oContext.getProperty("value");

     switch(typeof value)

     {

         case "string":

             return new sap.ui.commons.TextField(sId, {

                 value: {

                     path: "value",

                     //type: new sap.ui.model.type.String();

                 }

             });

         case "number":

             return new sap.ui.commons.TextField(sId, {

                 value: {

                     path: "value",

                    // type: new sap.ui.model.type.Float();

                 }

             });

         case "boolean":

             return new sap.ui.commons.CheckBox(sId, {

                 checked: {

                     path: "value"

                 }

             });

     }

  });

  });

  </script>

  </head>

  <body class="sapUiBody" role="application">

  <div id="content"></div>

  </body>

</html>

After some debug via fireBug, I saw it threw errors with code lines that look like:

type: new sap.ui.model.type.

So I commented them out..

However theres another error now that says:

Aggregation "content" does not exist in Element sap.ui.core.ComponentContainer#oContainer



Whats it that I am doing wrong here...


Thanks for all your help ...


Amjad

View Entire Topic
jmoors
Active Contributor
0 Likes

Hi,

The ComponentContainer doesn't provide a 'content aggregation', so you can't bind the content in this manner.

https://sapui5.hana.ondemand.com/sdk/#docs/api/symbols/sap.ui.core.ComponentContainer.html

You also don't need to define the data in the jQuery ready block.

Regards,

Jason

Former Member
0 Likes

Thanks for your answer Jason, i appreciate it..

However I picked this example from the Developer guide here SAPUI5 SDK - Demo Kit

Theres a snippet of code there that shows how bindAggregation could be accomplished using factory methods...

I can remove the code from the ready function though..

Please tell me how could binAggregation be done with factory methods if this example is incorrect..

Thanks a ton in advance for responding...