Skip to Content
avatar image
-1
Former Member

sapui5: bind odata with xml view in 2nd view

handler code in first controller:

// handle item selection
handleLineItemPress : function(evt){
//Create app object
var app = new sap.m.App({
initialPage : this.createId("idlecture1")
});

//Create detail page
var page = sap.ui.view({
id : this.createId("idlecture1"),
viewName : "zy_ws16_708_university_management.lecture",
type : sap.ui.core.mvc.ViewType.XML
});


//Pass data to detail page
var context = evt.getSource().getBindingContext();

app.to(page,{
ctx:context
});

//show detail page in app
app.addPage(page);
app.placeAt("content","only");



},

2nd controller code:

onInit: function() {
//Instantiate Odata model
var serviceUrl = "/sap/opu/odata/sap/ZY_WS16_708_UM_SRV/";
oModel = new sap.ui.model.odata.v2.ODataModel(serviceUrl);
this.getView().setModel(oModel);

var view = this.getView();
view.addDelegate({
onBeforeShow : function(evt){
view.setBindingContext(evt.data.ctx);
}
});
},

2nd view code:

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:f="sap.ui.layout.form"
controllerName="zy_ws16_708_university_management.lecture" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Lecture" showNavButton="true" navButtonPress="onBack">
<content>
<VBox class= "sapUiSmallMargin">
<f:SimpleForm id="idlecture1" title="Update Lecture Details">
<f:content id="lectures11">
<Label text="Lecture ID"/>
<Text text="{Id}"/>

<Label text="Name"/>
<Text text="{Name}"/>

<Label text="Room Number"/>
<Text text="{RoomNumber}"/>

<Label text="Lecturer"/>
<Text text="{Lecturer}"/>

<Label text="Type"/>
<Text text="{myName}"/>

<Label text="Offered In"/>
<Text text="{OfferedIn}"/>

<Label text="Weekly Hours"/>
<Text text="{WeeklyHours}"/>

<Label text="Content"/>
<Text text="{Content}"/>

<Label text="Prerequisites"/>
<Text text="{Prerequisites}"/>

<Label text="Organisation"/>
<Text text="{Organisation}"/>

<Label text="Credits"/>
<Text text="{Credits}"/>

<Label text="Language of Instruction"/>
<Text text="{LanguageOfInstruction}"/>

</f:content>
</f:SimpleForm>
</VBox>
</content>
</Page>
</core:View>

Please help! and let me know if there is anything wrong!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers