Java jsf1.2 rich:messages以相同的形式复制rich:message的验证

Java jsf1.2 rich:messages以相同的形式复制rich:message的验证,java,spring,richfaces,jsf-1.2,Java,Spring,Richfaces,Jsf 1.2,我正在使用JSF/SpringWebFlow和mvc应用程序准备一个注册页面。我添加了两个端验证,一个在客户端,每个输入字段都有自己的rich:message,另一个在服务器端,注册bean响应为facescontext.addMessage()。我的问题当我尝试测试验证时,rich:message组件显示正确的错误,但是rich:messages也显示相同的错误。我只想对特定的错误使用消息,比如数据库中已经存在邮件 my rich:messages标签: <rich:messages i

我正在使用JSF/SpringWebFlow和mvc应用程序准备一个注册页面。我添加了两个端验证,一个在客户端,每个输入字段都有自己的rich:message,另一个在服务器端,注册bean响应为facescontext.addMessage()。我的问题当我尝试测试验证时,rich:message组件显示正确的错误,但是rich:messages也显示相同的错误。我只想对特定的错误使用消息,比如数据库中已经存在邮件

my rich:messages标签:

<rich:messages id="msg" layout="table" limitRender="true"
            style="font-weight:bold;color:#BDBDBD">
            <f:facet name="errorMarker">
                <h:graphicImage url="/images/messages_error.png" />
            </f:facet>
        </rich:messages>

<h:form ...>
   .....SOME LOGIC.....

<h:inputText id="i_ln" required="true" value="#{regBean.lastName}">
    <f:validateLength minimum="2" maximum="35" />
    <rich:ajaxValidator event="onblur" />
</h:inputText>
<rich:message for="i_ln">
    <f:facet name="errorMarker">
       <h:graphicImage url="/images/messages_error.png" />
    </f:facet>
</rich:message>
       .....
    </h:form>
另一个问题是我应该保持服务器端验证吗

好,这里有一个解决方法: 首先,它是一个已知的问题,指:

第二个解决方案,用于包含多个rich的页面:消息

我添加了一个隐藏的rich:message用作桥接器,这样我的消息就可以有隐藏的组件id,并且在我用这个id从我的rich:messages中提取它之后,它将不会为null

<rich:message id="nonExistClient" rendered="false"/>
<a4j:form id="messagesForm">
    <rich:messages id="msg" layout="list"
        style="font-weight:bold;color:#BDBDBD" 
        for="nonExistClient">
        <f:facet name="errorMarker">
            <h:graphicImage url="/images/messages_error.png" />
        </f:facet>
    </rich:messages>
</a4j:form>
Hi guys,

We investigated the issue further by debugging the RichFaces JavaScript code.

We noticed that both the <rich:messages globalOnly="true" /> component and the <rich:message for="inputField" /> component bind to an "onMessage" event.

When the event is triggered on tab, the "onMessage" function in "message.js.faces" is triggered for both components.

    As you can see in the attached screenshots the function is called twice: once for both components. Other <rich:message /> components which have a "for" attribute related to other fields are not triggered, just as expected.
    In the JavaScript code, we can see that a check is performed on the availability of the "forComponentId" attribute. If this attribute is available, a validation message is rendered for the specified component id. If this is not available, a global message is rendered.
    But when a global message is rendered, we cannot see any check on the globalOnly attribute. So any message is rendered, regardless of this attribute. The attribute is nowhere to be found in the JavaScript code.

    We were wondering if this is the bug or if there is an other piece of code that is responsible for checking whether only global error messages may be displayed?
   <rich:messages id="msg" layout="list"
        style="font-weight:bold;color:#BDBDBD" 
        globalOnly="true">
        <f:facet name="errorMarker">
            <h:graphicImage url="/images/messages_error.png" />
        </f:facet>
    </rich:messages>
private void addSeverityError(String message)
    {
        FacesContext context = FacesContext.getCurrentInstance();
        FacesMessage fMessage = new FacesMessage();
        fMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
        fMessage.setSummary(message);
        fMessage.setDetail("Validation error");
        context.addMessage(null, fMessage);
    }
<rich:message id="nonExistClient" rendered="false"/>
<a4j:form id="messagesForm">
    <rich:messages id="msg" layout="list"
        style="font-weight:bold;color:#BDBDBD" 
        for="nonExistClient">
        <f:facet name="errorMarker">
            <h:graphicImage url="/images/messages_error.png" />
        </f:facet>
    </rich:messages>
</a4j:form>
private void addSeverityError(String message)
{
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage fMessage = new FacesMessage();
    fMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
    fMessage.setSummary(message);
    fMessage.setDetail("Validation error");
    context.addMessage("nonExistClient", fMessage);
}