Can I separate Messages from Message?

UI Components for JSF
Post Reply
User avatar
Crystal
Posts: 18
Joined: 20 Jul 2010, 22:38
Location: CT. USA

25 Jul 2010, 20:54

Hi,

On my form I would like to have main messages like 'System ' displayed across the top and I would like messages regarding field displayed only next to the field. The field messages are displaying next to the field and on the top. I found a way to fix this but I was hoping there is an easier way. I fixed it by setting
<p:messages id="msgs" showDetail="true" showSummary="false" rendered="#{create.renderMessage}"/>
and passing in true or false to specify when it should and should not render.

Let me know if I coded something wrong and there is an easier way, or is this just how Messages / Message works?

Code: Select all

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                template="/templates/BoxLayout.xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="center">
        <p:ajaxStatus style="height:19px;width:220px">
            <f:facet name="start">
                <h:graphicImage value="/resources/images/ajax-loader.gif" />
                <!--<h:graphicImage value="#{request.contextPath}/faces/resources/images/ajax-loader.gif" />-->
            </f:facet>
            <f:facet name="complete">
                <h:outputText value="" />
            </f:facet>
        </p:ajaxStatus>
        <h:form prependId="false">
            <h:panelGrid id="errGrid" columns="1">
                <p:messages id="msgs" showDetail="true" showSummary="false"/>
            </h:panelGrid>
        </h:form>
        <h:form prependId="false">
            <h:panelGrid id="grid" columns="3">
                <h:outputText value="Manufacturer" />
                <h:inputText id="manufacturer" value="#{create.manufacturer}" required="true"/>
                <p:message for="manufacturer"/>
                <h:outputText value="Serial Number"/>
                <h:inputText id="serialNumber" value="#{create.serialNumber}" required="true"/>
                <p:message for="serialNumber"/>
                <h:outputText value="Part Number" />
                <h:inputText id="partNumber" value="#{create.partNumber}" required="true"/>
                <p:message for="partNumber"/>
            </h:panelGrid>
            <p:commandButton value="Submit" action="#{create.createBox}" update="grid,errGrid"/>
        </h:form>
    </ui:define>
</ui:composition>
Thanks!
Using primefaces-2.1.RC1.jar, Mojarra JSF 2.0.3, GlassFish 3

User avatar
Crystal
Posts: 18
Joined: 20 Jul 2010, 22:38
Location: CT. USA

25 Jul 2010, 22:16

Looks like
<p:messages id="msgs" showDetail="true" showSummary="false" globalOnly="true"/>
fixes that issue.

:) problem solved
Using primefaces-2.1.RC1.jar, Mojarra JSF 2.0.3, GlassFish 3

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

26 Jul 2010, 00:41

Yes, with globalOnly you can configure p:messages to only show messages that are not associated with a particular component.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 48 guests