PrimeFaces确认对话框在更改语言后将不会显示

问题描述 投票:0回答:1

我有一个带有数据表的表格。在其中一列中是删除该行的按钮。该按钮上附有一个素面确认对话框。

<h:form id="form" style="text-align: -webkit-center">
            <p:dataTable id="preferenceConfigs" var="preferenceConfig"
                         value="#{preferenceManagementBackingBean.preferenceConfigs}">
                <p:column style="width:6rem; text-align: center">
                    <p:commandButton update=":form"
                                     title="#{msgs['common.delete.userpreference.button']}"
                                     icon="fa fa-trash"
                                     action="#{preferenceManagementBackingBean.invalidatePreferenceConfig(preferenceConfig)}">
                        <p:confirm header="Confirmation" message="#{msgs['common.dialog.preference.config.warning']}"
                                   icon="fa fa-exclamation-circle" escape="false"/>
                    </p:commandButton>
            </p:dataTable>

            <p:confirmDialog global="true" showEffect="fade" hideEffect="fade" style="text-align-last: center">
                <p:commandButton value="#{msgs['common.dialog.confirm.yes']}" type="button"
                                 styleClass="ui-confirmdialog-yes" icon="fa fa-check"/>
                <p:commandButton value="#{msgs['common.dialog.confirm.no']}" type="button"
                                 styleClass="ui-confirmdialog-no" icon="fa fa-times"/>
            </p:confirmDialog>
        </h:form>

一切正常,直到我通过CommandLink更改页面上的语言。它们位于该文件上方的masterLayout文件中:

<h:form id="generalSettingsForm">
                            <ul id="language">
                                <li><h:commandLink
                                        action="#{languageSessionBean.changeLanguage('en')}" value="EN"
                                        class="blgm_lSwitch" id="EN"/></li>
                                <li><h:commandLink
                                        action="#{languageSessionBean.changeLanguage('nl')}" value="NL"
                                        class="blgm_lSwitch" id="NL"/></li>
                                <li><h:commandLink
                                        action="#{languageSessionBean.changeLanguage('fr')}" value="FR"
                                        class="blgm_lSwitch" id="FR"/></li>
                            </ul>
                        </h:form>
    public void changeLanguage(String language) {
        locale = new Locale(language);
        findCurrentFacesContext().getViewRoot().setLocale(locale);
    }

这将刷新页面并显示正确的语言。但是,现在按下删除按钮会自动执行操作,而不会显示任何确认对话框。仅当我打开另一个对话框(在JSF页面中存在)并返回时,确认才会再次显示其外观...

任何见识?

java primefaces jsf-2 java-ee-7
1个回答
0
投票

您可以尝试将p:confirmDialog放在表格之外吗?像这样的东西:

<p:confirmDialog global="true" showEffect="fade" hideEffect="fade" style="text-align-last: center">
    <p:commandButton value="#{msgs['common.dialog.confirm.yes']}" type="button"
                     styleClass="ui-confirmdialog-yes" icon="fa fa-check"/>
    <p:commandButton value="#{msgs['common.dialog.confirm.no']}" type="button"
                     styleClass="ui-confirmdialog-no" icon="fa fa-times"/>
</p:confirmDialog>

<h:form id="form" style="text-align: -webkit-center">
    <p:dataTable id="preferenceConfigs" var="preferenceConfig"
        value="#{preferenceManagementBackingBean.preferenceConfigs}">
        <p:column style="width:6rem; text-align: center">
            <p:commandButton update=":form" icon="fa fa-trash"
                title="#{msgs['common.delete.userpreference.button']}"
                action="#{preferenceManagementBackingBean.invalidatePreferenceConfig(preferenceConfig)}">
                <p:confirm header="Confirmation" message="#{msgs['common.dialog.preference.config.warning']}"
                           icon="fa fa-exclamation-circle" escape="false"/>
        </p:commandButton>
    </p:dataTable>
</h:form>
© www.soinside.com 2019 - 2024. All rights reserved.