SAPUI5我无法从Rest服务加载表

时间:2015-12-22 13:36:08

标签: rest sapui5 loaddata

我遇到了麻烦。我可以从同一个本地Json加载我的表,但是,当我读取Rest时,我无法加载表。因为我测试过,两人都回来了Json。 这个错误会与Syncronous和Asyncronous有关吗?

这是无效的代码

        var oModelGET = new JSONModel();
        var urlGET = 'http://localhost/Compliance/api/RestServiceImpl.svc/getTFCompanyList';
        var parametersGET = {};

        var headersGET = {
            "Accept": "application/json",
            "X-Invoiceware-Token": oModelPOST.getProperty("/Token"),
            "Content-Type": "application/json"
        };
        oModelGET.loadData(urlGET, parametersGET, false, "GET", false, "false", headersGET);
        this.setModel(oModelGET, "products");

此代码正常运行:

        // set invoice model - local
        var oInvoiceModel = new JSONModel()
        var invoiceLocal = "/test/localService/mockdata/Products.json";
        var sNamespace = "sap.ui.compliance";

        oInvoiceModel.loadData(jQuery.sap.getModulePath(sNamespace, invoiceLocal));
        this.setModel(oInvoiceModel, "products");

这是我的xml

<core:View
   controllerName="controller.security.Companies"
    xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
xmlns:core="sap.ui.core"
xmlns="sap.m">
  <Page title="{i18n>companiesViewTitle}">
   <content>
   <Table busyIndicatorDelay="{worklistView>/tableBusyDelay}"
         class="sapUiResponsiveMargin"
         growing="true"
         growingScrollToLoad="true"
               id="tableCompanies"
         items="{ path: 'products>/Products', sorter: { path: 'products>/Name', descending: false } }"
         noDataText="{worklistView>/tableNoDataText}"
                 updateFinished="onUpdateFinished" width="auto">
    <headerToolbar>
      <Toolbar>
        <Title id="tableCompanyHeader" text="Companies (n)"/>
        <ToolbarSpacer/>
        <SearchField id="searchField" search="onSearch" tooltip="Search" width="auto"></SearchField>
        <Button type="Default" icon="sap-icon://add" press="handleNewCompanypress"/>
      </Toolbar>
    </headerToolbar>
    <columns>
      <Column id="companyCol" minScreenWidth="Small" demandPopin="true">
        <Text text="Company" />
      </Column>
      <Column id="nameCol" minScreenWidth="Small" demandPopin="true">
        <Text text="Name" />
      </Column>
    </columns>
    <items>
      <ColumnListItem press="handleListItempress" type="Navigation">
        <cells>
          <ObjectIdentifier
            title="{products>Name}"/>
          <Text
            text="{products>SearchCode}" />
        </cells>
      </ColumnListItem>
    </items>
  </Table>
  </content>
  <footer>
  <OverflowToolbar id="otbFooter">
  </OverflowToolbar>
  </footer>
  </Page>
  </core:View>

谢谢

0 个答案:

没有答案