简体   繁体   中英

OpenUI5 XML View attribute as variable

I'm using OpenUI5 and have an overall framework XMLView and Controller and want to display another XMLView dynamically based on certain conditions. eg

<mvc:View controllerName="openui5.view.Framework" xmlns="sap.m"
xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" >

<Page id="frameworkPage" title="{i18n>DetailTitle}" showNavButton="true"
    navButtonPress="onBack">
    <Button id="saveButton" text="Save" type="Accept" icon="sap-icon://save"
        press="onSave" />
    <Button id="nextButton" text="Next" type="Accept" icon="sap-icon://action"
        press="onNext" />
    <content>   
        <mvc:XMLView id="subView" viewName="{myViewVariable}"></mvc:XMLView>
    </content>
</Page>

Is it possible to specify a value to myViewVariable dynamically at runtime?

Cheers,XML

I'm quite sure there's no possibility for something like conditionals or data binding for the specification of your content in the XML View. There are two possibilities I know of:

  • You could leave your content tag empty and add content during runtime using the addContent(oContent) method in your controller dynamically eg inside an event handler for a button.
  • You could switch to JSView instead of XML. There you could use things like conditionals and loops but consider: in comparison to the first solution it will only do this once at the initialization of your view

You might be able to do something similar with the release of 1.28. This update is going to introduce XML Templating .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM