在index.html中插入某些代码后出现的问题

时间:2018-02-06 07:07:14

标签: sapui5

我是SAP UI5和Fiori的新手。我正在开发SAP Web IDE中的第一个应用程序。非常简单 - 它有2个视图。我试图从一个视图导航到另一个视图并面临问题。我想我并没有正确宣布我的观点。我的主视图工作正常,但在 index.html 中插入某些代码后,它开始抛出错误。它还说控制器中的navTo方法是undefined。有时,我收到错误消息,sapundefined。我想我也错过了一些文库。

的index.html

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta charset="UTF-8">

    <title>temp_test</title>

    <script id="sap-ui-bootstrap"
      src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js"
      data-sap-ui-libs="sap.m"
      data-sap-ui-theme="sap_belize"
      data-sap-ui-compatVersion="edge"
      data-sap-ui-resourceroots='{"temp_test": "./"}'
    ></script>
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <script>
      sap.ui.getCore().attachInit(function() {
        sap.ui.xmlview("MainPage1",{
          viewName: "temp_test.view.xmlnamepage"
        }).placeAt("content");
        /*sap.ui.xmlview("OrderMgmt1",{
          viewName : "temp_test.view.testingagain"
        }).placeAt("content");*/
      });
    </script>
  </head>
  <body class="sapUiBody" id="content"></body>
</html>

MainView.Controller

sap.ui.define([
  "sap/ui/core/mvc/Controller",
  "sap/m/MessageToast",
  "sap/ui/model/json/JSONModel",
  "jquery.sap.global"
], function(Controller, MessageToast, JSONModel, jQuery) {
  "use strict";

  return Controller.extend("temp_test.controller.xmlnamepage", {
    onInit: function () {
      //moved to Component
    },

    press: function(evt) {
      MessageToast.show("The GenericTile is pressed.");
    },

    orderMgmt: function(evt) {
      var context = evt.getSource().getBindingContext();
      this.getRouter().navTo("OrderMgmt1");
    },

  });
});

xmlnamepage.xml

<mvc:View
  controllerName="temp_test.controller.xmlnamepage"
  xmlns:l="sap.ui.layout"
  xmlns:mvc="sap.ui.core.mvc"
  xmlns="sap.m"
  displayBlock="true"
>
  <App>
    <Page title="Inventory Management">
      <l:VerticalLayout width="100%">
        <Panel class= "T2" width="100%">
          <headerToolbar>
            <Toolbar class="T1">
              <Title  level="H2" text="Site Overview"/>
            </Toolbar>
          </headerToolbar>
          <FlexBox
            class="columns"
            alignItems="Center"
          >
            <Label
              text="Filter Stockroom"
              labelFor="input-a"
            />
            <SearchField id="input-a"
              width="340px"
              class="sapUiSmallMargin"
            />
            <Button
              text="Apply"
              type="Emphasized"
              class="sapUiSmallMarginEnd"
            />
            <Button
              text="Reset"
              type="Emphasized"
              class="sapUiSmallMarginEnd"
            />
          </FlexBox>
          <FlexBox
            height="50%"
            alignItems="Start"
            justifyContent="Start"
          >
            <GenericTile
              class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout AA"
              header="Inventory"
              subheader="1000 Parts managed"
              frameType="TwoByOne"
              press="press"
            >
              <TileContent>
                <ImageContent src="sap-icon://inventory"/>
              </TileContent>
            </GenericTile>
            <GenericTile
              class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout"
              header="Orders"
              subheader="Back Orders"
              frameType="TwoByOne"
              press="press"
            >
              <TileContent>
                <ImageContent src="sap-icon://inventory"/>
              </TileContent>
            </GenericTile>
          </FlexBox>
        </Panel>
        <Panel class="T2">
          <headerToolbar>
            <Toolbar class="T1">
              <Title level="H2" text="Views you have access to" />
            </Toolbar>
          </headerToolbar>
          <FlexBox
            height="50%"
            alignItems="Start"
            direction="Row"
            justifyContent="Start"
          >
            <GenericTile
              class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout D"
              header="Order Management"
              press="orderMgmt"
            >
              <TileContent>
                <ImageContent src="sap-icon://order-status"/>
              </TileContent>
            </GenericTile>
            <GenericTile
              class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout C"
              header="Payment Management"
              press="press"
            >
              <TileContent>
                <ImageContent src="sap-icon://monitor-payments"/>
              </TileContent>
            </GenericTile>
            <GenericTile
              class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout D"
              header="Stockroom Management"
              press="press"
            >
              <TileContent>
                <ImageContent src="sap-icon://product"/>
              </TileContent>
            </GenericTile>
            <GenericTile
              class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout D"
              header="Supplier Management"
              press="press"
            >
              <TileContent>
                <ImageContent src="sap-icon://supplier"/>
              </TileContent>
            </GenericTile>
            <items class= "FI">
            <FeedInput
              post="onPost"
              icon="sap-icon://inventory"
              class="sapUiSmallMarginTopBottom FI"
            />
            <List
              showSeparators="Inner"
              items="{/EntryCollection}"
            >
              <FeedListItem
                sender="{Author}"
                icon="{AuthorPicUrl}"
                senderPress="onSenderPress"
                iconPress="onIconPress"
                iconDensityAware="false"
                info="{Type}"
                timestamp="{Date}"
                text="{Text}"
                convertLinksToAnchorTags="All"
              />
            </List>
          </FlexBox>
        </Panel>
      </l:VerticalLayout>
    </Page>
  </App>
</mvc:View>

testingagain.xml

<mvc:View
  xmlns:core="sap.ui.core"
  xmlns:mvc="sap.ui.core.mvc"
  xmlns="sap.m"
  controllerName="temp_test.controller.testingagain"
>
  <App>
    <Page title="new test title">
    </Page>
  </App>
</mvc:View>

2 个答案:

答案 0 :(得分:0)

你能先解释一下你的问题吗? 您不能在对象中使用val p = """(\d+\s+minutes?)""".r.unanchored val s = "last 12 minutes." val res = s match { case p(m) => m case _ => "" } // => 12 minutes ,在您尝试在var对象中使用它的情况下。 您的代码的sap.m.Shell部分是错误的,您应该指向某个目录,例如data-sap-ui-resourceroots='{"temp_test": ""}'> 我建议你试试walk-through provided by SAP in their SDK。 此外,您可能会发现有助于首先完成this course

答案 1 :(得分:0)

请查看Demo

您在manifest.json中缺少的是什么,您必须添加类似于此的内容,这将在上述链接的第2步中介绍。

"routing": {
     "config": {
        "routerClass": "sap.m.routing.Router",
        "viewType": "XML",
        "viewPath": "sap.ui.demo.nav.view",
        "controlId": "app",
        "controlAggregation": "pages",
        "transition": "slide"
        "async": true
     },
     "routes": [{
        "pattern": "",
        "name": "appHome",
        "target": "home"
     }],
     "targets": {
        "home": {
           "viewId": "home",
           "viewName": "Home",
           "viewLevel" : 1
        }
     }
  }