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

Cant get To Run AggregationBinding Example :(

Former Member
0 Likes
582

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
Former Member
0 Likes

Hey Jason,

I figured that out

The oContainer in the sample should not refer to the ComponentContainer as it doesnt have the property "content"

It should rather refer to some component that has one .. such as sap.ui.commons.Panel

Cheers!

TobiasMeinzer
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Amjad,

thanks for this interesting discussion!

Would you mind posting the final coding with which you made this sample code running?

I am still struggling with that..

Many thanks!
Tobias