Jsf p:未在primefaces对话框中显示的消息

Jsf p:未在primefaces对话框中显示的消息,jsf,primefaces,dialog,messages,display,Jsf,Primefaces,Dialog,Messages,Display,我在Primefaces 6中的对话框中有一个p:messages,但是这个元素没有显示任何内容。它只是不显示在屏幕上。我正在bean中设置错误消息,但它不显示该消息。我希望错误消息显示在对话框中。我已经尝试更新commandbutton和Bean中的p:messages。代码如下: 豆子: public void persist(){ 布尔错误=假; addErrorMessage(“schedule\u summary\u error\u message”,“FUMBLE!出了问题!请再试一

我在Primefaces 6中的对话框中有一个p:messages,但是这个元素没有显示任何内容。它只是不显示在屏幕上。我正在bean中设置错误消息,但它不显示该消息。我希望错误消息显示在对话框中。我已经尝试更新commandbutton和Bean中的p:messages。代码如下:

豆子:

public void persist(){
布尔错误=假;
addErrorMessage(“schedule\u summary\u error\u message”,“FUMBLE!出了问题!请再试一次。”,null);//添加了这一行,以便错误消息无论发生什么都可以显示,但仍然不显示。
对于(int i=0;i
xhtml:

<p:dialog id="newScheduleDialog" appendToBody="true" responsive="true" widgetVar="newScheduleDialog" header="Creating the game schedule" 
position="center top" closeOnEscape="true" width="60%" modal="true" style="overflow-y:auto;max-height:100%">
<p:ajax event="close" oncomplete="PF('createScheduleWizard').loadStep(PF('createScheduleWizard').cfg.steps[0], true)" />
   <h:form id="schedule_form">
      <p:wizard id="createScheduleWizard" widgetVar="createScheduleWizard" showStepStatus="false" flowListener="#{scheduleWizard.onFlowProcess}" showNavBar="false" >
        <p:tab id="summaryTab" title="Summary">
            <p:messages id="schedule_summary_error_message" for="schedule_summary_error_message" showDetail="true" showSummary="false" autoUpdate="true" closable="true" />                                                     
            <p style="text-align: center;" class="sansation_bold16">Summary </p> 

            <ui:include src="../pages/matchup_carousel.xhtml" />
            <p:commandButton value="Save and publish schedule" id="saveButton" widgetVar="saveButton" actionListener="#{matchupBean.persist}"
                              style=" -webkit-border-radius: 6px; border-radius: 6px; margin-top:20px"/>
        </p:tab>

    </p:wizard>
</h:form>

总结

我以前从未见过在“for”属性中使用与元素本身id相同的id。尝试在邮件的“for”上使用不同的id(可能是表单的id)。尝试:


在添加代码中缺少的错误消息后,您需要添加javascript代码段以显示对话框。

刚刚尝试了此操作,但没有成功。消息仍然没有显示。我添加这个p:messages的原因是,每当我们在数据库事务中遇到异常或任何其他异常时,都会显示一条错误消息。这正是与问题相关的代码片段。此时,对话框已显示。确定。由于commandbutton在默认情况下触发ajax调用,因此您需要使用commandbutton上的update属性更新消息组件,以便在ajax完成后更新消息。只是尝试了一下,但不起作用,但理论上我们不应该这样做,因为我们有autoUpdate=“true”关于消息:如果消息确实被添加到支持bean中,那么它的更新问题就会出现在页面上。您可以使用sysout语句验证它。。然后您可以尝试在命令按钮上使用update=“@all”。
<p:dialog id="newScheduleDialog" appendToBody="true" responsive="true" widgetVar="newScheduleDialog" header="Creating the game schedule" 
position="center top" closeOnEscape="true" width="60%" modal="true" style="overflow-y:auto;max-height:100%">
<p:ajax event="close" oncomplete="PF('createScheduleWizard').loadStep(PF('createScheduleWizard').cfg.steps[0], true)" />
   <h:form id="schedule_form">
      <p:wizard id="createScheduleWizard" widgetVar="createScheduleWizard" showStepStatus="false" flowListener="#{scheduleWizard.onFlowProcess}" showNavBar="false" >
        <p:tab id="summaryTab" title="Summary">
            <p:messages id="schedule_summary_error_message" for="schedule_summary_error_message" showDetail="true" showSummary="false" autoUpdate="true" closable="true" />                                                     
            <p style="text-align: center;" class="sansation_bold16">Summary </p> 

            <ui:include src="../pages/matchup_carousel.xhtml" />
            <p:commandButton value="Save and publish schedule" id="saveButton" widgetVar="saveButton" actionListener="#{matchupBean.persist}"
                              style=" -webkit-border-radius: 6px; border-radius: 6px; margin-top:20px"/>
        </p:tab>

    </p:wizard>
</h:form>
<p:messages id="schedule_summary_error_message" for="schedule_summary" showDetail="true" showSummary="false" autoUpdate="true" closable="true" />   
addErrorMessage("schedule_summary", "Something went wrong! Try it again.", null);