简体   繁体   中英

Duplicated JSF messages

I'm using JSF with Richfaces and any message shows an error in the console and generates two repeated messages.

I have this XHTML:

<h:form>                    
            <h:panelGrid columns="3">
                <h:outputLabel value="Proyecto" />                  
                <h:selectOneMenu id="cbo_proyecto" value="#{planMaestro.idProyecto}" required="true" requiredMessage="Debe seleccionar un proyecto.">
                    <f:selectItem itemValue="0" itemLabel="Seleccione" itemDisabled="true"/>
                    <f:selectItems value="#{planMaestro.listaProyectos}" var="p"
                        itemValue="#{p.idProyecto}" itemLabel="#{p.nombre}" />
                </h:selectOneMenu>
                <h:commandButton value="Seleccionar" action="#{planMaestro.mostrarCampos()}"/>
            </h:panelGrid>              
        </h:form>

I obtain this in the console:

18:57:14,217 INFORMACIÓN [javax.enterprise.resource.webcontainer.jsf.renderkit] (http-localhost-127.0.0.1-8080-5) ADVERTENCIA: FacesMessage(s) se han puesto en la cola, pero es posible que no se muestren.
sourceId=j_idt42:cbo_proyecto[severity=(ERROR 2), summary=(Debe seleccionar un proyecto.), detail=(Debe seleccionar un proyecto.)]
18:57:14,235 INFORMACIÓN [javax.enterprise.resource.webcontainer.jsf.renderkit] (http-localhost-127.0.0.1-8080-5) ADVERTENCIA: FacesMessage(s) se han puesto en la cola, pero es posible que no se muestren.
sourceId=j_idt42:cbo_proyecto[severity=(ERROR 2), summary=(Debe seleccionar un proyecto.), detail=(Debe seleccionar un proyecto.)]

If I use h:message or h:messages I won't have any problem even though the errors are shown in the console, but I'm using:

<rich:notifyMessages stayTime="4000" nonblocking="true" showDetail="true" showSummary="false"/>

and it shows two repeated messages instead of one.

The <rich:notifyMessages> tag shows all the available messages, in this case both local and global messages. To avoid double message you may set globalOnly attribute ture .

Please note there is another tag <rich:notifyMessage> for local messages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM