Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PrimeFaces confirmDialog赢得';改变语言后不显示_Primefaces_Jsf 2 - Fatal编程技术网

PrimeFaces confirmDialog赢得';改变语言后不显示

PrimeFaces confirmDialog赢得';改变语言后不显示,primefaces,jsf-2,Primefaces,Jsf 2,我有一个表单,里面有一个数据表。其中一列中有一个删除该行的按钮。该按钮附带了一个primefaces确认对话框 <h:form id="form" style="text-align: -webkit-center"> <p:dataTable id="preferenceConfigs" var="preferenceConfig" value="#{preferenceManagementBackin

我有一个表单,里面有一个数据表。其中一列中有一个删除该行的按钮。该按钮附带了一个primefaces确认对话框

<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>
这将刷新页面并显示正确的语言。但是,现在按下“删除”按钮会自动执行该操作,而不会出现任何确认对话框的迹象。只有当我打开另一个对话框(在JSF页面中出现)并返回时,确认才会再次出现

开发人员控制台显示以下错误:

VM1391 components.js.xhtml:13 Uncaught TypeError: Cannot read property 'style' of undefined
    at c.show (VM1391 components.js.xhtml:13)
    at c.showMessage (VM1391 components.js.xhtml:13)
    at Object.confirm (VM1391 components.js.xhtml:1)
    at Object.confirm (VM1390 core.js.xhtml:1)
    at HTMLButtonElement.onclick (preferenceManagement.xhtml:58)

有什么见解吗?

你能试着把
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>

confirmDialog似乎不能很好地使用ajax更新

通常,语言更改意味着页面的所有部分都必须更新,因此使用部分更新没有任何好处

解决此问题的简单方法是在CommandLink上将ajax设置为false:

<h:commandLink action="#{languageSessionBean.changeLanguage('fr')}" 
               value="FR" class="blgm_lSwitch" id="FR" ajax="false" />

在谷歌搜索了一段时间后,primefaces 6.2似乎出现了以下问题:

confirmDialog不显示,控制台上记录了一个错误(TypeError: this.jqEl未定义)

这已在6.2.2中修复。我不能亲自测试,因为所有的小版本都只面向付费用户。作为解决方法,我将尝试使用自定义对话框。也可以使用primefaces 7.0


使用primefaces 6.2版本,同样的事情发生在我身上,然后努力搜索,我发现这个解决方案非常有效,我希望它能帮助某些人,在web xml中添加:

<context-param>
   <param-name>primefaces.MOVE_SCRIPTS_TO_BOTTOM</param-name>
   <param-value>true</param-value>
</context-param>

primefaces.MOVE_SCRIPTS_至_底部
真的

commandLink在哪里?我已经编辑了这个问题,将commandLink包括在内。它位于“主”JSF页面中。。。。总是……我在下面找到了“解决方案”。它还有一个复制器。问题仍然存在。你能试试这个吗?不要把答案变色。如果您想提出一个新答案,请创建一个新答案。不幸的是,它不会改变行为
<h:commandLink action="#{languageSessionBean.changeLanguage('fr')}" 
               value="FR" class="blgm_lSwitch" id="FR" ajax="false" />
<context-param>
   <param-name>primefaces.MOVE_SCRIPTS_TO_BOTTOM</param-name>
   <param-value>true</param-value>
</context-param>