for global messages try

<h:messages globalOnly="true" errorClass="errMsgStyle" infoClass="
infoMsgStyle" showSummary="true" showDetail="true" />

Vinod


                                                                                
                                                              
                    Ray Clark                                                   
                                                              
                    <[EMAIL PROTECTED]       To:     MyFaces Discussion 
<[email protected]>                                       
                    hoo.com>             cc:                                    
                                                              
                                         Subject:     Re: FacesMessage question 
                                                              
                    04/12/2005                                                  
                                                              
                    08:28 AM                                                    
                                                              
                    Please respond                                              
                                                              
                    to "MyFaces                                                 
                                                              
                    Discussion"                                                 
                                                              
                                                                                
                                                              
                                                                                
                                                              




Hi Rob, thanks for trying, but this didn't seem to
help.

I changed the code to be like this:

FacesContext.getCurrentInstance().addMessage("body",
           new FacesMessage(FacesMessage.SEVERITY_ERROR,
                     "summary message", "detail message"));

When I put the messages tag in my page like you
suggest:

<h:messages id="body" layout="table"
styleClass="message" showSummary="true"
showDetail="false"/>

I get a "java.lang.IllegalStateException: parent is
null?" exception.

When I leave the id attribute off, it doesn't throw an
exception but of course it doesn't work either.

So I tried this:

<h:message for="body" showSummary="true"
showDetail="true"/>

This doesn't show a message either.  It doesn't throw
an exception, it just doesn't seem to do anything.

I know the message is getting into the context because
I can execute this and the message gets printed out.

Iterator iter =
FacesContext.getCurrentInstance().getMessages();
while (iter.hasNext()) {
           FacesMessage msg = (FacesMessage) iter.next();
           System.out.println("severity=" + msg.getSeverity()
                     + ", summary=" + msg.getSummary()
                     + ", detail=" + msg.getDetail());
}

I was using null instead of "body" because I thought I
read in the javadoc that null meant that it was a
global message.  But changing it to null and adding
the globalOnly="true" attribute to the messages tag
didn't do a think either.

Anybody got any other ideas?

Surely people are using h:message or h:messages to put
out messages to the users from a method other than a
converter or validator.

I'm using MyFaces 1.0.8, what are you using Rob?

Thanks,
Ray

--- Robert Breidecker <[EMAIL PROTECTED]> wrote:
> Ray,
>
> You need to set the client id when adding the
> message
> to FacesContext.
>
> The last line in your code example would be...
> context.addMessage("myClientId", message);
>
> Your JSP messages tag would be...
> <h:messages id="myClientId" layout="table"
> styleClass="message" showSummary="true"
> showDetail="false"/>
>
> Hope this helps.
>
> Rob Breidecker
>
>
>
>
> --- Ray Clark <[EMAIL PROTECTED]> wrote:
> > I have a method in a managed bean that is getting
> > called.  I wish to put a message on the page to
> > inform
> > the user that the operation that he/she requested
> > was
> > performed correctly.  I can successfully do this
> > with
> > a variable in the managed bean.  My problem is
> that
> > I
> > was wanting to use the built in FacesMessage class
> > for
> > this if possible.  Here is my code to add my
> > message:
> >
> > FacesMessage message = new FacesMessage();
> > message.setSeverity(FacesMessage.SEVERITY_ERROR);
> > message.setSummary("Add was successful");
> > message.setDetail("Add was successful");
> > FacesContext context =
> > FacesContext.getCurrentInstance();
> > context.addMessage(null, message);
> >
> > It does add the message to the context because I
> can
> > use System.out to print it out right after that.
> > The
> > problem is that the message doesn't display on the
> > page.  I do get other Faces messages displayed so
> I
> > don't believe it is a problem with the JSP.  I'm
> > wondering if FacesMessage was not designed to be
> > used
> > like this.  Is FacesMessage only designed to be
> used
> > in the converter and validator?
> >
> > Has anyone else been able to put a message in the
> > context and been able to print it out on the page?
> >
> > Here is my JSP snippet.
> >
> > <h:messages layout="table" styleClass="message"
> > showSummary="true" showDetail="false"/>
> > <h:messages layout="table" styleClass="message"
> > showSummary="false" showDetail="true"/>
> >
> >
> > Thanks,
> > Ray
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Make Yahoo! your home page
> > http://www.yahoo.com/r/hs
> >
>
>
>
> __________________________________
> Do you Yahoo!?
> Make Yahoo! your home page
> http://www.yahoo.com/r/hs
>



__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/




Reply via email to