primefaces对话框关闭使主页上的输入被禁用

时间:2018-08-08 15:06:41

标签: java primefaces primefaces-dialog-framework

这是对话框代码

<title><ui:insert name="title">#{msg['trip.bus.unsaved.warning']}</ui:insert></title>
    <h:outputStylesheet library="css" name="theme.css" />
</h:head>

<h:body>
    <ui:composition>
    <h:form id="unsavedBusValidationReturnToCharterForm" width="450px">
        <p:panelGrid columns="1">
            <p:row>
                <p:outputLabel value="#{msg['trip.bus.unsaved.validation.string1']}" style="color:red; font-weight:bold; font-size:12px;"/>
            </p:row>
            <p:row>
                <p:outputLabel value="#{msg['trip.bus.unsaved.validation.string2']}" style="color:red; font-weight:bold; font-size:12px"/>
            </p:row>
            <p:row>
                <p:outputLabel value="#{msg['trip.bus.unsaved.validation.string3']}" style="color:red; font-weight:bold; font-size:12px"/>          </p:row>
        </p:panelGrid>
        <p:commandButton value="#{msg['trip.bus.cancellation.button.ok']}" style="width:140px;" type="submit" onclick="PF('unsavedBusValidReturnToChartDialog').hide();"
        action="#{tripInformationController.returnToTripInfo}" update="busPg">
            <!-- <f:ajax listener="PF('unsavedBusValidReturnToChartDialog').hide();" /> -->
        </p:commandButton>
        <p:spacer width="4px"></p:spacer>
        <p:commandButton value="#{msg['trip.bus.cancellation.button.cancel']}" style="width:140px;"
        onclick="PF('unsavedBusValidReturnToChartDialog').hide();"></p:commandButton>
        </h:form>
    </ui:composition>
</h:body>
</html>

这是包含该代码的对话框

            <p:dialog widgetVar="unsavedBusValidReturnToChartDialog" showHeader="true" showEffect="clip" hideEffect="clip" appendToBody="true" width="auto"
                height="auto" resizable="true" draggable="true" modal="true"
                styleClass="customDialog dialogTitleNone">
                    <ui:include src="/charter/unsaved_bus_validation_return_to_charter.xhtml" />
            </p:dialog>

然后,当我单击“确定”以浏览回一页时,此方法将运行。

public String returnToTripInfo() {
        logger.info("returnToTripInfo() entry");
        doRemoveUnsavedBus();

        if (getBusInfoListVo().size() > 0) {
            busbutton = "Edit Buses";
            List<FinancialDetailVo> tempFinancialDetails = busInfoSer.getFinancialDetails(tripInfoVo.getCharterId());
            if (tempFinancialDetails != null && tempFinancialDetails.size()>0 ) {
                tripInfoVo.setFinancialDetailVoSet(tempFinancialDetails);
                calculateFinancialtotalAmount();
            }
            else
            {
                tripInfoVo.setFinancialDetailVoSet(null);
                tripInfoVo.setFinancialTotalAmount(null);
                calculateFinancialtotalAmount();

            }

            if(getBusInfoVo().getSelectStatus()==4)
            {
                setDisableBus(false);
                setDisableCharges(false);
                setDisableBusStatus(false);
                setDisableBusSave(false);
            }
        }
        logger.info("returnToTripInfo() exit");
        return "Charter_information_tab.xhtml";
    }

当对话框关闭并返回一个屏幕时,该屏幕上的输入字段就像被禁用一样。我尝试了appendToBody =“ true”和appendTo =“ @(body)”。我正在运行Primefaces版本6。

在对话框导航和关闭之后,我只需要导航到屏幕上的输入即可编辑。

1 个答案:

答案 0 :(得分:0)

页面在hideEffect能够完成之前正在导航,因此无法在页面导航之前关闭对话框。我把hideEffect拿出来了,对话框能够在导航之前完全关闭。

<p:dialog widgetVar="unsavedBusValidReturnToChartDialog" showHeader="true" showEffect="clip" appendToBody="true" width="auto"
                height="auto" resizable="true" draggable="true" modal="true"
                styleClass="customDialog dialogTitleNone">
                    <ui:include src="/charter/unsaved_bus_validation_return_to_charter.xhtml" />
            </p:dialog>