Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

DATA From Mockserver in Controller

Former Member
0 Likes
919

Hello,

i have a question and i hope somebody can help me...

I create a Odata Mock Service with an metadata.xml file.

<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:sap="http://www.sap.com/Protocols/SAPData">
	<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="2.0">
		<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="S1">
			<EntityType Name="Aktion">
				<Key>
					<PropertyRef Name="AktID"/>
				</Key>
				<Property Name="AktID" Type="Edm.Int32" Nullable="false"/>
				<Property Name="ArtId" Type="Edm.Int32" Nullable="false"/>
				<Property Name="Matnr" Type="Edm.String" Nullable="false"/>
				<Property Name="Bezeichnung" Type="Edm.String" Nullable="true"/>
				<NavigationProperty Name="Aktion_Aktionsdetail" Relationship="S1.FK_Aktion_Aktiondetail" ToRole="Aktiondetail" FromRole="Aktion"/>
			</EntityType>
					<EntityContainer Name="AktionEntities" m:IsDefaultEntityContainer="true" xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
				<EntitySet EntityType="S1.Aktion" Name="Aktions"/>
	</EntityContainer>
		</Schema>
	</edmx:DataServices>
</edmx:Edmx>

I can work with the Data in the view but i dont know, how to access the data in a controler.

I create a Model with the following name "Aktions".

var oModel2 = this.getOwnerComponent().getModel("Aktions");

Now how can i get the data from my model ?

Thank you....

Dominic

1 ACCEPTED SOLUTION
Read only

maheshpalavalli
Active Contributor
824

Hi Dominic,

you need to use 'read' method of odatamodel to access the data.

oModel2.read(.... ); // Pass path, success handler and error handler functions

https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/read

BR,

Mahesh

3 REPLIES 3
Read only

maheshpalavalli
Active Contributor
825

Hi Dominic,

you need to use 'read' method of odatamodel to access the data.

oModel2.read(.... ); // Pass path, success handler and error handler functions

https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/read

BR,

Mahesh

Read only

0 Likes
824

Thank you.... it works fine. I still have a lot to learn.

BR

Dominic

Read only

0 Likes
824

Cool.. Go through blogs in UI5 and especially Developer Guide completely, you will learn a lot of concepts in no time.

BR,

Mahesh