【问题标题】:How to do reload a page in SAPUI5?如何在 SAPUI5 中重新加载页面?
【发布时间】:2018-10-16 12:35:32
【问题描述】:

我想在使用 CRUD 保存数据后重新加载“菜单”页面。

var sUrl = "/sap/opu/odata/sap/ZGW_VISTORIA_SRV";
        var oModel = new sap.ui.model.odata.ODataModel(sUrl, true);
        var rota = this.getOwnerComponent().getRouter();
        var page = this;

        oModel.create('/vistoria', dados, null,
            function () {
                MessageBox.success('Cadastrado com sucesso!', {
                    onClose: function (sActionClicked) {
                        oStorage.clear();
                        oStorage.removeAll();
                        // oStorage.put("Save", {
                        //  isSave: true
                        // });
                        page.getView().exit();
                        page.getView().destroy();
                        // oStorage.get("Menu").menu.getModel().refresh(true);            
                        rota.navTo("Menu", false);
                        // window.location.reload(window.history.go(-3));
                        // sap.ui.getCore().byId("Menu").getModel().refresh(true);
                    }
                });
            },
            function () {
                MessageBox.error('Erro ao cadastrar o veiculo!');
            }
        );

我尝试了很多方法,因为我需要删除我保存在表单中的信息。 那么,你能帮帮我吗?

【问题讨论】:

  • 我的回答对你有用吗?还是您需要进一步的帮助?

标签: javascript sapui5


【解决方案1】:

首先,如果您下次发布所有相关代码(表格也是),那就太好了,
但我想我明白你想做什么。
重置表单,而不是重新加载页面
(重新加载整个 view 比仅重置 form 需要更长的时间)

要走的路是将input / checkbox 等的值绑定在模型中的表单内:

<Input
    id="someID"
    value="{urModel>/inputValue}"
    valueState="{vsModel>/vsInput}"
    valueStateText="{i18n>vstInput}"/>

然后在您的成功方法或您的创建中重置这些值:

urRemoteModel.create("/urSet", oEntry, {
    success: function(oRetrievedResult) {
        this.getView().getModel(urModel).setProperty("/inputValue", "");
        //some other stuff

    }.bind(this),
        error: function(oError) {
        //error handling
     }
});

【讨论】:

    【解决方案2】:

    对不起,我的延误。 我正在创建一个用于检查卡车的应用程序。当用户结束调查并保存时,他将被重定向到页面“菜单”。

    在该页面中,他可以选择进行新的调查,点击“地籍”图块。这里有必须清除的表格:

    <mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:form="sap.ui.layout.form" xmlns:core="sap.ui.core"
    controllerName="com.sap.build.standard.formInspecaoDeVeiculos.controller.Identificacao">
    <Page showHeader="true" title="Indenificação" showFooter="true" showNavButton="true" navButtonPress="_onPageNavButtonPress">
        <content>
            <Panel height="auto" width="auto" headerText="" expandable="false" expanded="true" expandAnimation="true" backgroundDesign="Solid"
                class="sapUiTinyMargin sapUiContentPadding">
                <content>
                    <form:Form width="100%" editable="true" visible="true">
                        <form:title>
                            <core:Title text="Veículo" level="Auto"/>
                        </form:title>
                        <form:formContainers>
                            <form:FormContainer visible="true">
                                <form:formElements>
                                    <form:FormElement visible="true">
                                        <form:label>
                                            <Label text="Veículo" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
                                        </form:label>
                                        <form:fields>
                                            <Input id="tratorInput" placeholder="Ex.: ABC1234" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
                                                valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Veiculo}"
                                                value="{ path : '/placa', type : '.customPlacaType' }" valueLiveUpdate="{/ValueLiveUpdate}" liveChange="handleLiveChange">
                                                <suggestionItems>
                                                    <core:Item text="{Placa}"/>
                                                </suggestionItems>
                                            </Input>
                                        </form:fields>
                                    </form:FormElement>
                                    <form:FormElement visible="true">
                                        <form:label>
                                            <Label text="Reboque(1)" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
                                        </form:label>
                                        <form:fields>
                                            <Input id="reboque1Input" placeholder="Ex.: ABC1234" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
                                                valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Reboque}"
                                                value="{ path : '/placa', type : '.customPlacaType' }" valueLiveUpdate="{/ValueLiveUpdate}" liveChange="handleLiveChange">
                                                <suggestionItems>
                                                    <core:Item text="{Placa}"/>
                                                </suggestionItems>
                                            </Input>
                                        </form:fields>
                                    </form:FormElement>
                                    <form:FormElement visible="true">
                                        <form:label>
                                            <Label text="Reboque(2)" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
                                        </form:label>
                                        <form:fields>
                                            <Input id="reboque2Input" placeholder="Ex.: ABC1234" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
                                                valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Reboque}"
                                                value="{ path : '/placa', type : '.customPlacaType' }" valueLiveUpdate="{/ValueLiveUpdate}" liveChange="handleLiveChange">
                                                <suggestionItems>
                                                    <core:Item text="{Placa}"/>
                                                </suggestionItems>
                                            </Input>
                                        </form:fields>
                                    </form:FormElement>
                                    <form:FormElement visible="true">
                                        <form:label>
                                            <Label text="Motorista" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
                                        </form:label>
                                        <form:fields>
                                            <Input id="motoristaInput" placeholder="Ex.: Nome do motorista" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
                                                valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Motorista}" valueLiveUpdate="{/ValueLiveUpdate}"
                                                liveChange="handleLiveChange" value="{ path : '/Name1', type: '' }">
                                                <suggestionItems>
                                                    <core:Item text="{Name1}"/>
                                                </suggestionItems>
                                            </Input>
                                        </form:fields>
                                    </form:FormElement>
                                    <form:FormElement visible="true">
                                        <form:label>
                                            <Label text="CPF" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit" visible="true"/>
                                        </form:label>
                                        <form:fields>
                                            <Input id="cpfInput" placeholder="Ex.: 00000000000" type="Text" showValueHelp="true" enabled="true" visible="true" width="auto"
                                                valueHelpOnly="false" maxLength="0" valueHelpRequest="handleValueHelp" suggestionItems="{/Motorista}" valueLiveUpdate="{/ValueLiveUpdate}"
                                                liveChange="handleLiveChange">
                                                <suggestionItems>
                                                    <core:Item text="{Stcd2}"/>
                                                </suggestionItems>
                                            </Input>
                                        </form:fields>
                                    </form:FormElement>
                                </form:formElements>
                                <form:title/>
                            </form:FormContainer>
                        </form:formContainers>
                        <form:layout>
                            <form:ResponsiveGridLayout adjustLabelSpan="false" columnsL="2" labelSpanL="3" columnsM="1" labelSpanM="2" labelSpanS="12"/>
                        </form:layout>
                    </form:Form>
                </content>
            </Panel>
        </content>
        <footer>
            <OverflowToolbar width="100%" height="auto" design="Auto" enabled="true" visible="true">
                <content>
                    <ToolbarSpacer width=""/>
                    <Button text="" type="Emphasized" icon="sap-icon://navigation-right-arrow" iconFirst="true" width="auto" enabled="true" visible="true"
                        iconDensityAware="false" press="_onContinue"/>
                </content>
            </OverflowToolbar>
        </footer>
        <headerContent/>
        <subHeader/>
        <customHeader/>
    </Page>
    

    在我的输入中,我使用“路径:/placa”设置了 de 属性值,因为我使用了一个助手进行搜索。在下一页“Conclusao”中,用户完成调查。我的问题:如何从另一个页面中的页面访问模型?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-09
      • 2016-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-02
      • 1970-01-01
      相关资源
      最近更新 更多