<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
<script id="sap-ui-bootstrap"
src="https://sdk.openui5.org/nightly/resources/sap-ui-core.js"
data-sap-ui-async="true"
data-sap-ui-modules="sap/ui/thirdparty/sinon,sap/ui/thirdparty/datajs,demo/localService/mockserver"
data-sap-ui-onInit="module:demo/init"
data-sap-ui-resourceRoots='{ "demo": "./" }'
data-sap-ui-excludeJQueryCompat="true"
data-sap-ui-compatVersion="edge"
data-sap-ui-xx-waitfortheme="init"
></script>
</head>
<body id="content" class="sapUiBody">
<div data-sap-ui-component
data-id="rootComponentContainer"
data-name="demo"
data-height="100%"
data-settings='{ "id": "rootComponent" }'
></div>
</body>
</html>
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/core/Configuration",
"sap/ui/core/ComponentSupport",//https://github.com/SAP/ui5-tooling/issues/381
], (UIComponent, Configuration) => {
"use strict";
return UIComponent.extend("demo.Component", {
metadata: {
interfaces: [
"sap.ui.core.IAsyncContentCreation",
],
manifest: "json",
},
init() {
UIComponent.prototype.init.apply(this, arguments);
const detectedLang = Configuration.getLanguage();
this.getModel("clientModel").setProperty("/", { number: "22000.01" });
this.getModel("currentLanguage").setProperty("/", detectedLang);
},
});
});
{
"_version": "1.48.0",
"start_url": "index.html",
"sap.app": {
"id": "demo",
"type": "application",
"title": "Demo",
"description": "Sample Code",
"applicationVersion": {
"version": "1.0.0"
},
"dataSources": {
"MyNodes": {
"uri": "/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
}
},
"sap.ui": {
"technology": "UI5",
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
}
},
"sap.ui5": {
"handleValidation": true,
"dependencies": {
"minUI5Version": "1.96",
"libs": {
"sap.ui.core": {},
"sap.m": {}
}
},
"models": {
"": {
"dataSource": "MyNodes",
"preload": true,
"settings": {
"defaultBindingMode": "TwoWay"
}
},
"currentLanguage": {
"type": "sap.ui.model.json.JSONModel"
},
"clientModel": {
"type": "sap.ui.model.json.JSONModel"
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"rootView": {
"viewName": "demo.view.Root",
"id": "rootView",
"type": "XML",
"async": true,
"height": "100%",
"displayBlock": true
}
}
}
<mvc:View xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:core="sap.ui.core"
core:require="{
ODataDecimalType: 'sap/ui/model/odata/type/Decimal',
FloatType: 'sap/ui/model/type/Float'
}"
displayBlock="true"
height="100%"
>
<App autoFocus="false">
<Page
showHeader="false"
binding="{/OrderSet(10248)}"
class="sapUiResponsiveContentPadding"
>
<VBox renderType="Bare">
<Input
value="{
path: 'Freight',
type: 'ODataDecimalType',
formatOptions: {
maxFractionDigits: 3,
minFractionDigits: 2
},
constraints: {
maximum: '99999.999',
scale: '2'
}
}"
/>
<ObjectAttribute
title="Actual value in ODataModel"
text=""{Freight}""
/>
<Input class="sapUiSmallMarginTop"
value="{
path: 'clientModel>/number',
type: 'FloatType',
formatOptions: {
maxFractionDigits: 3,
minFractionDigits: 2,
parseAsString: true,
emptyString: 0,
roundingMode: 'AWAY_FROM_ZERO'
},
constraints: {
maximum: '99999.99'
}
}"
/>
<ObjectAttribute
title="Actual value in ClientModel"
text=""{clientModel>/number}""
/>
<ObjectStatus class="sapUiMediumMarginTop"
title="Detected language"
text="{currentLanguage>/}"
state="Information"
inverted="true"
/>
</VBox>
</Page>
</App>
</mvc:View>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<edmx:Edmx Version="1.0"
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:sap="http://www.sap.com/Protocols/SAPData">
<edmx:DataServices m:DataServiceVersion="2.0">
<Schema Namespace="Demo" xml:lang="en" sap:schema-version="1">
<EntityType Name="Order">
<Key>
<PropertyRef Name="OrderID" />
</Key>
<Property Name="OrderID" Type="Edm.Int32" Nullable="false"/>
<Property Name="Freight" Type="Edm.Decimal" Nullable="false" />
</EntityType>
<EntityContainer Name="DemoEntities" m:IsDefaultEntityContainer="true">
<EntitySet Name="OrderSet" EntityType="Demo.Order" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
sap.ui.define([
"sap/ui/core/util/MockServer",
], (MockServer) => {
"use strict";
return {
init: function() {
MockServer.config({
autoRespond: true,
autoRespondAfter: 0,
});
const mockServer = new MockServer({
rootUri: "/",
recordRequests: false,
});
const pathPrefix = sap.ui.require.toUrl("demo/localService");
mockServer.simulate(`${pathPrefix}/metadata.xml`, {
sMockdataBaseUrl: `${pathPrefix}/mockdata`,
});
mockServer.start();
}
};
});
[
{
"OrderID": 10248,
"Freight": "22000"
}
]
sap.ui.require([
"demo/localService/mockserver",
], mockserver => {
"use strict";
mockserver.init();
sap.ui.require([ "sap/ui/core/ComponentSupport" ]);
});