cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 - Context transfer

MariusStoica
Active Participant
0 Kudos

Hi guys,

I'm having a problem transferring 2 OData models to the same page. I'm not using spitapp. Let me explain

I have 3 pages.

In the first page I navigate from a list with :


handleListSelect : function (evt) {

var app = sap.ui.getCore().byId("App--app");

var context = evt.getParameter("listItem").getBindingContext();

app.to("App--orderView", context);

},

and when I get in the "Order" page, I do this:


onInit : function(evt) {

  // binding model synchronisation

  this.getView().addDelegate({ onBeforeShow: function(evt) {

   if (this.direction != "back") {

    evt.to.setModel(evt.data.oModel);

    evt.to.setBindingContext(evt.data);

   } //endif

  } //endfunc onBeforeShow

  }); //endDelegate

},

On the Order page, I have the "Add product button" that takes me to the third page.

From that page, I navigate back to the Order page using something similar to the first navigation:


onAddPress : function (oEvt) {

  var aContexts = this.getView().byId("idMaterialsList").getSelectedContexts(true);

  var app = sap.ui.getCore().byId("App--app");

  app.to("App--orderView", aContexts);

}

But when I get back to the Order page, from the Materials page 2 things happened:

1. The data from the first oModel gets overwritten by the new data from the new oModel

2. The selected from the Materials list doesn't show up in the Order items list:


    <List id      ="idMaterialsList"

      items     ="{/Materials}"

            selectionChange   ="onSelectionChange"

            mode     ="MultiSelect"

      includeItemInSelection ="true">

     <!-- <items> -->

      <ObjectListItem

       title="{Material}"

       type="Inactive"

       number="11"

       numberUnit="numberUnit"

       press="handleListItemPress"  >

       <attributes>

        <ObjectAttribute text="{Description}" />

       </attributes>

       <firstStatus>

        <ObjectStatus text="3"/>

       </firstStatus>

      </ObjectListItem>

     <!-- </items>-->

    </List>

Any idea how can I improve this ?

Thank you,
Marius

PS: Do you think I should add this question in the "UI Development Toolkit for HTML5 Developer Center" thread also ?

Accepted Solutions (0)

Answers (1)

Answers (1)

kedarT
Active Contributor
0 Kudos

Hi Marius,

Try to move the value of "this" to another variable "that" and use it in function onAddPress instead of "this".