Page Is Blank Without Throwing Any Errors

后端 未结 2 567

I am trying to display few tiles in a tile container which fetches data from a dummy JSON file. I have coded exactly shown in this sample. But my page appears empty. Also it

相关标签:
2条回答
  • 2020-12-20 06:20

    Causes for Empty Page Related to TileContainer

    Unexpected Child Control

    Besides the missing root control, the <TileContainer> currently contains a list of HBoxes in your view.

    <TileContainer id="container" tiles="{/MovieCollection}">
      <HBox>
         <StandardTile .../>
      </HBox>
    </TileContainer>
    

    The default aggregation of TileContainer is, however, a control that is derived from sap.m.Tile.

    Hence, you should be getting the following error message in the browser console:

    Uncaught Error: "Element sap.m.HBox#__hbox1" is not valid for aggregation "tiles" of Element sap.m.TileContainer#__xmlview1--container

    Please, remove the <HBox> from the ListBinding template:

    <TileContainer id="container" tiles="{/MovieCollection}">
      <StandardTile .../>
    </TileContainer>
    

    TileContainer Contains only one Tile

    There was a bug in the framework which didn't let the TileContainer to display anything if it contained only a single Tile. The fix should be available as of UI5 version 1.48.

    0 讨论(0)
  • 2020-12-20 06:32

    Your root view is missing a root control such as sap.m.AppAPI which:

    • Writes a bunch of properties into the header of HTML document, e.g. the viewport meta tag,
    • Writes height: 100% to all its parent elements.[src]

    Without a root control, the content will be displayed improperly. Hence, adding an <App> should be sufficient in your case:

    <!-- root view -->
    <mvc:View
      xmlns:mvc="sap.ui.core.mvc"
      xmlns="sap.m"
      height="100%"
      displayBlock="true"
      controllerName="..."
    >
      <App id="myApp"> <!-- Not in other views! -->
        <!-- content -->
      </App>
    </mvc:View>
    

    The reason why the linked sample is working, is that the control sap.m.App was already added in index.html. The samples shown in the Demo Kit, however, often miss index.html in the code page to be shown which can be confusing.


    Alternatively, without sap.m.App, you could also add the following in index.html and in the root view:

    1. Add 100% height to <html>, and to <div data-sap-ui-component> if it exists.

      <html style="height: 100%;">
       <head>
         <!-- ... -->
         <script id="sap-ui-bootstrap" src="..."
           data-sap-ui-modules="sap/ui/core/ComponentSupport"
           data-...>
         </script>
       </head>
       <body id="content" class="sapUiBody">
         <div style="height: 100%;"
           data-sap-ui-component
           data-height="100%"
           data-...>
         </div>
       </body>
      </html>

    2. And in the root view:
      <mvc:View height="100%" ...>
        <!-- no <App> here -->

    Example: https://embed.plnkr.co/6AJKC0

    This will make the content visible too but without the need to use sap.m.App in the root view.

    0 讨论(0)
提交回复
热议问题