myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Myfaces Wiki] Update of "Create and Display Messages" by RickReumann
Date Fri, 09 Sep 2005 15:33:14 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by RickReumann:

New page:
'''From Mike Kienenberger, posted on MyFaces mailing list:'''

<h:messages globalOnly="true" showDetail="true"/>
<h:message for="<optionalRelatedComponentId>" showDetail="true"/>

FacesContext facesContext = FacesContext.getCurrentInstance();

                   new FacesMessage(FacesMessage.SEVERITY_<WHATEVER>,
                       "<messageSummary>", "<messageDetail>"));

optionalRelatedComponentReference.getClientId(facesContext) can be
replaced with null if you want a global message.

'''Mike's example of the above in use:'''

This is an example of how I've used it.  Note that I can change to any
kind of UIInput to represent an externalCustomerLastName, and my code
remains unchanged.  Probably not as useful for a last name field, but
for input components that might change between inputCalendars or
pulldowns or inputText fields, it's very helpful.

   private transient UIInput externalCustomerLastNameInput;
   public UIInput getExternalCustomerLastNameInput()
       return this.externalCustomerLastNameInput;
   public void setExternalCustomerLastNameInput(
           UIInput externalCustomerLastNameInput)
       this.externalCustomerLastNameInput = externalCustomerLastNameInput;

                   new FacesMessage(FacesMessage.SEVERITY_ERROR,
                       "Last name mismatch", "The last name doesn't
match the record found."));

<h:outputLabel for="ExternalCustomerLastNameInput">
   <h:outputText value="Customer Last Name:"/>
<h:inputText id="ExternalCustomerLastNameInput"
<h:message for="ExternalCustomerLastNameInput" styleClass="errors"

View raw message