无法在xhtml页面上显示面孔消息 [英] Unable to show faces message on xhtml page

查看:70
本文介绍了无法在xhtml页面上显示面孔消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用facesMessage显示面孔消息

I am unable to show faces messages using facesMessage

Bean代码:

if(condition){
    FacesContext fc=FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL,"Rounding Rule Saved","R Saved"));
}

查看代码:

<p:messages autoUpdate="true" showDetail="true" globalOnly="true" id="msgId"/>

但是我没有收到消息,我在做什么错了?

But I am not getting messages, what am I doing wrong?

我的项目流程是:

  1. 用户单击查看页面上的编辑按钮
  2. 重定向到编辑页面
  3. 提交返回查看页面后
  4. 呈现消息(我没有收到)

查看代码(rouning_rule_master.xhtml):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0     Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"      
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      > 
    <ui:composition template="/pages/webEx_Template.xhtml">
        <ui:define name="content">
            <h:head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title>Rounding Rule Master</title>
                <link rel="stylesheet" type="text/css" href="../css/rounding_rule_master.css" />

            </h:head>
            <h:body>
                <div class="wrapper">
                    <div class="page_wrapper">

                        <div class="page_heading border_bottom">Rounding Rule Master</div>

                        <div class="form_div">
                            <h:form  id="roundingMasterFormId" >
                                <p:messages autoUpdate="true" showDetail="true" globalOnly="true" id="MESSAGEID"/>
                                <div class="form_detail">
                                    <div class="float_right">
                                        <h:commandButton id="creataeBtn" action="#{roundingBean.createRoundingRule}" value="Create   Rounding Rule" class="createRelation"  >
                                            <p:ajax onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
                                        </h:commandButton>
                                    </div>
                                    <div class="clear"></div>


                                    <div style="margin:10px 0;">
                                        <table id="roundingMasterTableId" width="100%" cellspacing="1" cellpadding="0" border="0" class="role_detail_section">
                                            <thead>
                                                <tr>
                                                    <th>Rounding Rule Id</th>
                                                    <th>Rounding Rule Name</th>
                                                    <th>Rounding Mode</th>
                                                    <th>Rounding Constant</th>
                                                    <th class="action">Action</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                            <c:forEach items="#{roundingBean.roundingRuleList}" var="var" >
                                                <tr>    
                                                <h:inputHidden value="#{var.roundingRuleId}" /> 
                                                <td><h:outputText value="#{var.roundingRuleId}" /></td>
                                                <td><h:outputText value="#{var.roundingRuleName}" /></td>
                                                <td><h:outputText value="#{var.roundingMode.roundingModeName}" /></td>
                                                <td><h:outputText value="#{var.roundingIncrement}" /></td>
                                                <td>
                                                <p:commandLink value="Edit" styleClass="edit_icon" action="#{roundingBean.editRoundingRule    (var,true)}" immediate="true" process="@this" onstart="statusDialog.show();" onsuccess="statusDialog.hide();">
                                                </p:commandLink>
                                                <p:commandLink id="deleteId" styleClass="remove_icon" action="#{roundingBean.deleteRoundingRule(var.roundingRuleId)}" immediate="true" update="@form" process="@this" oncomplete="addCSS()" onstart="statusDialog.show();" onsuccess="statusDialog.hide();">
                                                    <p:confirm header="Confirmation" message="Are you sure want to delete rounding rule ?" icon="ui-icon-alert" />Delete
                                                </p:commandLink>
                                                </td>
                                                </tr>
                                            </c:forEach>
                                            </tbody>
                                        </table>
                                    </div>




                                </div>

                                <p:confirmDialog styleClass="confirm" global="true" showEffect="fade" draggable="false" closable="false" resizable="false" width="400">  
                                    <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes"/>  
                                    <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no"/>       
                                </p:confirmDialog>
                                <p:dialog styleClass="confirm" modal="true" widgetVar="statusDialog" header="Loading..."
                                          draggable="false" closable="false" resizable="false" width="100"
                                          height="50">
                                    <div align="center">
                                        <p:graphicImage value="../images/loading.gif" width="50"
                                                        height="50" />
                                    </div>
                                </p:dialog>
                            </h:form>
                        </div>
                    </div>
                </div>
            </h:body>
        </ui:define>
    </ui:composition>
</html>

推荐答案

我不确定是否是您的情况.但是,如果您在生成消息后进行重定向,则它们将在重定向过程中丢失.您需要确保在页面流中,faces配置中没有重定向-或任何其他方式.

I am not sure if it is your case. But if you redirect after generating the Messages, they are lost in the redirect process. You need to make sure there is no redirect in the faces config - or any other mean - in your page flow.

这篇关于无法在xhtml页面上显示面孔消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆