diff --git a/webapp/controller/Detail.controller.js b/webapp/controller/Detail.controller.js
index 2db97b3..826b1fa 100644
--- a/webapp/controller/Detail.controller.js
+++ b/webapp/controller/Detail.controller.js
@@ -1,19 +1,45 @@
sap.ui.define([
"jquery.sap.global",
- "sap/ui/core/mvc/Controller"
-], function (jQuery, Controller) {
+ "sap/ui/core/mvc/Controller",
+ "sap/ui/model/json/JSONModel"
+], function (jQuery, Controller, JSONModel) {
"use strict";
return Controller.extend("ui5confUI5Conf.controller.Detail", {
onInit: function () {
+ this.getRouter().attachRouteMatched(this._handleRouteChanged.bind(this));
},
+ _itemDetail: null,
+ _handleRouteChanged: function (oEvent) {
+ var oView = this.oView,
+ oModel = this.oView.getModel(),
+ oData = oModel.getData(),
+ sProductId = oEvent.getParameter("arguments")["detail-item"],
+ oItemData = oData["ProductCollection"].filter(function (oCurItem) {
+ return oCurItem.ProductId === sProductId;
+ })[0];
+
+ this._itemDetail = sProductId;
+
+ if (oItemData) {
+ oView.setModel(new JSONModel(oItemData), "detail");
+ }
+ },
+
getRouter: function () {
return sap.ui.core.UIComponent.getRouterFor(this);
},
- handlePress: function () {
+ handlePress: function (oEvent) {
+ var sId = oEvent.getParameter("id"),
+ oSelectedItem = sap.ui.getCore().byId(sId),
+ // It's important to point that we're getting the second model, not the default one
+ oModel = oSelectedItem.getModel("detailDetail"),
+ sPath = oSelectedItem.getBindingContextPath(),
+ oData = oModel.getProperty(sPath);
+
this.getRouter().navTo("detailDetailName", {
- "detail-detail-item": "item-inner1",
- "detail-item": "item1"
+ "detail-detail-item": oData.ProductId,
+ "detail-item": this._itemDetail
});
},
toggleFooter: function () {
diff --git a/webapp/controller/DetailDetail.controller.js b/webapp/controller/DetailDetail.controller.js
index 102a4ca..79c5037 100644
--- a/webapp/controller/DetailDetail.controller.js
+++ b/webapp/controller/DetailDetail.controller.js
@@ -1,11 +1,31 @@
sap.ui.define([
"jquery.sap.global",
- "sap/ui/core/mvc/Controller"
-], function (jQuery, Controller) {
+ "sap/ui/core/mvc/Controller",
+ "sap/ui/model/json/JSONModel"
+], function (jQuery, Controller, JSONModel) {
"use strict";
return Controller.extend("ui5confUI5Conf.controller.DetailDetail", {
onInit: function () {
+ this.getRouter().attachRouteMatched(this._handleRouteChanged.bind(this));
+ },
+ getRouter: function () {
+ return sap.ui.core.UIComponent.getRouterFor(this);
+ },
+ _itemDetail: null,
+ _handleRouteChanged: function (oEvent) {
+ var oView = this.oView,
+ // Be aware to fetch the proper model!
+ oModel = this.oView.getModel("detailDetail"),
+ oData = oModel.getData(),
+ sProductId = oEvent.getParameter("arguments")["detail-detail-item"],
+ oItemData = oData["ProductCollection"].filter(function (oCurItem) {
+ return oCurItem.ProductId === sProductId;
+ })[0];
+
+ if (oItemData) {
+ oView.setModel(new JSONModel(oItemData), "detail");
+ }
},
toggleFooter: function () {
var oObjectPageLayout = this.getView().byId("ObjectPageLayout");
diff --git a/webapp/manifest.json b/webapp/manifest.json
index 33009bb..582edf3 100644
--- a/webapp/manifest.json
+++ b/webapp/manifest.json
@@ -62,6 +62,10 @@
"": {
"type": "sap.ui.model.json.JSONModel",
"uri": "model/products.json"
+ },
+ "detailDetail": {
+ "type": "sap.ui.model.json.JSONModel",
+ "uri": "model/products_less.json"
}
},
"resources": {
diff --git a/webapp/model/products_less.json b/webapp/model/products_less.json
new file mode 100644
index 0000000..f353fbc
--- /dev/null
+++ b/webapp/model/products_less.json
@@ -0,0 +1,42 @@
+{
+ "title" : "Products List",
+ "showFooter" : false,
+ "headerExpanded": true,
+ "titleClickable": true,
+ "ProductCollection": [
+ {
+ "ProductId": "1239102",
+ "Name": "Power Projector 4713",
+ "Category": "Projector",
+ "SupplierName": "Titanium"
+ },
+
+ {
+ "ProductId": "K47322.1",
+ "Name": "Hurricane GX",
+ "Category": "Graphics Card",
+ "SupplierName": "Red Point Stores"
+ },
+
+ {
+ "ProductId": "P1239823",
+ "Name": "Monitor Locking Cable",
+ "Category": "Accessory",
+ "SupplierName": "Technocom"
+ },
+
+ {
+ "ProductId": "214-121-828",
+ "Name": "Laptop Case",
+ "Category": "Accessory",
+ "SupplierName": "Red Point Stores"
+ },
+
+ {
+ "ProductId": "OP-38800002",
+ "Name": "High End Laptop 2b",
+ "Category": "Laptop",
+ "SupplierName": "Titanium"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/webapp/view/Detail.view.xml b/webapp/view/Detail.view.xml
index dcecd5a..697ce0a 100644
--- a/webapp/view/Detail.view.xml
+++ b/webapp/view/Detail.view.xml
@@ -10,10 +10,14 @@
-
+
+
@@ -22,6 +26,8 @@
+
+
@@ -39,7 +45,6 @@
-
@@ -49,7 +54,7 @@
-
+
@@ -62,8 +67,11 @@
-
+
+
+
+
diff --git a/webapp/view/DetailDetail.view.xml b/webapp/view/DetailDetail.view.xml
index 5584d45..f3c6451 100644
--- a/webapp/view/DetailDetail.view.xml
+++ b/webapp/view/DetailDetail.view.xml
@@ -10,18 +10,25 @@
+
-
+
-
+
+
+
@@ -34,6 +41,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+