You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Rick Reumann <ri...@gmail.com> on 2005/09/09 16:19:25 UTC

How to setup and display non-error messages

I'm looking in the section of Core JSF on "messages" but I don't see
how to create a typical "Your update of John Doe was Successful" type
of message to be used on a JSP.

How do you accomplish this with JSF/MyFaces? 

It seems like h:message and h:messages is really only geard for error
type messages, but what about standard success type message?

Actually, I don't even see how to set up error messages. For example
if I make a call to some backend procedure and want to display a
failure message, how do I do this?

TIA,

-- 
Rick

Re: How to setup and display non-error messages

Posted by Mike Kienenberger <mk...@gmail.com>.
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;
    }

facesContext.addMessage(externalCustomerLastNameInput.getClientId(facesContext),
                    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:outputLabel>
<h:inputText id="ExternalCustomerLastNameInput"
    binding="#{page.externalCustomerLastNameInput}" 
    value="#{dataModel.externalCustomerLastName}"/>
<h:message for="ExternalCustomerLastNameInput" styleClass="errors"
showDetail="true"/>

On 9/9/05, Rick Reumann <ri...@gmail.com> wrote:
> Mike, could you explain more the concept of the
> "optionalRelatedComponentReference" - what would be an example of its
> usage? Since I'm new, I haven't run across using the
> ComponentReference.getClientId construct yet.
> 
> (note: gmail might be adding my gmail address as the reply-to address
> instead of the list, and I have no idea why - so if someone replies to
> this make sure it has the list address. Anyone else besides Mike and I
> noticing gmail doing this?)
> 
> On 9/9/05, Mike Kienenberger <mk...@gmail.com> wrote:
> > <h:messages globalOnly="true" showDetail="true"/>
> > <h:message for="<optionalRelatedComponentId>" showDetail="true"/>
> >
> > FacesContext facesContext = FacesContext.getCurrentInstance();
> >
> > facesContext.addMessage(<optionalRelatedComponentReference>.getClientId(facesContext),
> >                     new FacesMessage(FacesMessage.SEVERITY_<WHATEVER>,
> >                         "<messageSummary>", "<messageDetail>"));
> >
> > optionalRelatedComponentReference.getClientId(facesContext) can be
> > replaced with null if you want a global message.
> >
> >
> > On 9/9/05, Rick Reumann <ri...@gmail.com> wrote:
> > > I'm looking in the section of Core JSF on "messages" but I don't see
> > > how to create a typical "Your update of John Doe was Successful" type
> > > of message to be used on a JSP.
> > >
> > > How do you accomplish this with JSF/MyFaces?
> > >
> > > It seems like h:message and h:messages is really only geard for error
> > > type messages, but what about standard success type message?
> > >
> > > Actually, I don't even see how to set up error messages. For example
> > > if I make a call to some backend procedure and want to display a
> > > failure message, how do I do this?
> > >
> > > TIA,
> > >
> > > --
> > > Rick
> > >
> >
> 
> 
> --
> Rick
>

Re: How to setup and display non-error messages

Posted by Rick Reumann <ri...@gmail.com>.
Mike, could you explain more the concept of the
"optionalRelatedComponentReference" - what would be an example of its
usage? Since I'm new, I haven't run across using the
ComponentReference.getClientId construct yet.

(note: gmail might be adding my gmail address as the reply-to address
instead of the list, and I have no idea why - so if someone replies to
this make sure it has the list address. Anyone else besides Mike and I
noticing gmail doing this?)

On 9/9/05, Mike Kienenberger <mk...@gmail.com> wrote:
> <h:messages globalOnly="true" showDetail="true"/>
> <h:message for="<optionalRelatedComponentId>" showDetail="true"/>
> 
> FacesContext facesContext = FacesContext.getCurrentInstance();
> 
> facesContext.addMessage(<optionalRelatedComponentReference>.getClientId(facesContext),
>                     new FacesMessage(FacesMessage.SEVERITY_<WHATEVER>,
>                         "<messageSummary>", "<messageDetail>"));
> 
> optionalRelatedComponentReference.getClientId(facesContext) can be
> replaced with null if you want a global message.
> 
> 
> On 9/9/05, Rick Reumann <ri...@gmail.com> wrote:
> > I'm looking in the section of Core JSF on "messages" but I don't see
> > how to create a typical "Your update of John Doe was Successful" type
> > of message to be used on a JSP.
> >
> > How do you accomplish this with JSF/MyFaces?
> >
> > It seems like h:message and h:messages is really only geard for error
> > type messages, but what about standard success type message?
> >
> > Actually, I don't even see how to set up error messages. For example
> > if I make a call to some backend procedure and want to display a
> > failure message, how do I do this?
> >
> > TIA,
> >
> > --
> > Rick
> >
> 


-- 
Rick

Re: How to setup and display non-error messages

Posted by Martin Marinschek <ma...@gmail.com>.
Yes!

Put it up - the wiki is yours!

regards,

Martin

On 9/9/05, Mike Kienenberger <mk...@gmail.com> wrote:
> Since you're finding it useful, perhaps you would create a wiki entry
> for it as a show of gratitude? :)
> 
> You're right in that I've posted the same info a couple of times now.
> 
> On 9/9/05, Rick Reumann <ri...@gmail.com> wrote:
> > Nice! Thanks. Is this in the wiki somewhere? If not, it should be:)
> >
> > (I still have trouble figuring out where to go for these 'how to'
> > questions. I try my Sun book first and then the wiki. I suppose I
> > could explore the java docs, but was hoping that could be avoided for
> > the basic stuff.)
> >
> > On 9/9/05, Mike Kienenberger <mk...@gmail.com> wrote:
> > > <h:messages globalOnly="true" showDetail="true"/>
> > > <h:message for="<optionalRelatedComponentId>" showDetail="true"/>
> > >
> > > FacesContext facesContext = FacesContext.getCurrentInstance();
> > >
> > > facesContext.addMessage(<optionalRelatedComponentReference>.getClientId(facesContext),
> > >                     new FacesMessage(FacesMessage.SEVERITY_<WHATEVER>,
> > >                         "<messageSummary>", "<messageDetail>"));
> > >
> > > optionalRelatedComponentReference.getClientId(facesContext) can be
> > > replaced with null if you want a global message.
> > >
> > >
> > > On 9/9/05, Rick Reumann <ri...@gmail.com> wrote:
> > > > I'm looking in the section of Core JSF on "messages" but I don't see
> > > > how to create a typical "Your update of John Doe was Successful" type
> > > > of message to be used on a JSP.
> > > >
> > > > How do you accomplish this with JSF/MyFaces?
> > > >
> > > > It seems like h:message and h:messages is really only geard for error
> > > > type messages, but what about standard success type message?
> > > >
> > > > Actually, I don't even see how to set up error messages. For example
> > > > if I make a call to some backend procedure and want to display a
> > > > failure message, how do I do this?
> > > >
> > > > TIA,
> > > >
> > > > --
> > > > Rick
> > > >
> > >
> >
> >
> > --
> > Rick
> >
> 


-- 

http://www.irian.at
Your JSF powerhouse - 
JSF Trainings in English and German

Re: How to setup and display non-error messages

Posted by Mike Kienenberger <mk...@gmail.com>.
Since you're finding it useful, perhaps you would create a wiki entry
for it as a show of gratitude? :)

You're right in that I've posted the same info a couple of times now.

On 9/9/05, Rick Reumann <ri...@gmail.com> wrote:
> Nice! Thanks. Is this in the wiki somewhere? If not, it should be:)
> 
> (I still have trouble figuring out where to go for these 'how to'
> questions. I try my Sun book first and then the wiki. I suppose I
> could explore the java docs, but was hoping that could be avoided for
> the basic stuff.)
> 
> On 9/9/05, Mike Kienenberger <mk...@gmail.com> wrote:
> > <h:messages globalOnly="true" showDetail="true"/>
> > <h:message for="<optionalRelatedComponentId>" showDetail="true"/>
> >
> > FacesContext facesContext = FacesContext.getCurrentInstance();
> >
> > facesContext.addMessage(<optionalRelatedComponentReference>.getClientId(facesContext),
> >                     new FacesMessage(FacesMessage.SEVERITY_<WHATEVER>,
> >                         "<messageSummary>", "<messageDetail>"));
> >
> > optionalRelatedComponentReference.getClientId(facesContext) can be
> > replaced with null if you want a global message.
> >
> >
> > On 9/9/05, Rick Reumann <ri...@gmail.com> wrote:
> > > I'm looking in the section of Core JSF on "messages" but I don't see
> > > how to create a typical "Your update of John Doe was Successful" type
> > > of message to be used on a JSP.
> > >
> > > How do you accomplish this with JSF/MyFaces?
> > >
> > > It seems like h:message and h:messages is really only geard for error
> > > type messages, but what about standard success type message?
> > >
> > > Actually, I don't even see how to set up error messages. For example
> > > if I make a call to some backend procedure and want to display a
> > > failure message, how do I do this?
> > >
> > > TIA,
> > >
> > > --
> > > Rick
> > >
> >
> 
> 
> --
> Rick
>

Re: How to setup and display non-error messages

Posted by Rick Reumann <ri...@gmail.com>.
Nice! Thanks. Is this in the wiki somewhere? If not, it should be:)

(I still have trouble figuring out where to go for these 'how to'
questions. I try my Sun book first and then the wiki. I suppose I
could explore the java docs, but was hoping that could be avoided for
the basic stuff.)

On 9/9/05, Mike Kienenberger <mk...@gmail.com> wrote:
> <h:messages globalOnly="true" showDetail="true"/>
> <h:message for="<optionalRelatedComponentId>" showDetail="true"/>
> 
> FacesContext facesContext = FacesContext.getCurrentInstance();
> 
> facesContext.addMessage(<optionalRelatedComponentReference>.getClientId(facesContext),
>                     new FacesMessage(FacesMessage.SEVERITY_<WHATEVER>,
>                         "<messageSummary>", "<messageDetail>"));
> 
> optionalRelatedComponentReference.getClientId(facesContext) can be
> replaced with null if you want a global message.
> 
> 
> On 9/9/05, Rick Reumann <ri...@gmail.com> wrote:
> > I'm looking in the section of Core JSF on "messages" but I don't see
> > how to create a typical "Your update of John Doe was Successful" type
> > of message to be used on a JSP.
> >
> > How do you accomplish this with JSF/MyFaces?
> >
> > It seems like h:message and h:messages is really only geard for error
> > type messages, but what about standard success type message?
> >
> > Actually, I don't even see how to set up error messages. For example
> > if I make a call to some backend procedure and want to display a
> > failure message, how do I do this?
> >
> > TIA,
> >
> > --
> > Rick
> >
> 


-- 
Rick

Re: How to setup and display non-error messages

Posted by Mike Kienenberger <mk...@gmail.com>.
<h:messages globalOnly="true" showDetail="true"/>
<h:message for="<optionalRelatedComponentId>" showDetail="true"/>

FacesContext facesContext = FacesContext.getCurrentInstance();

facesContext.addMessage(<optionalRelatedComponentReference>.getClientId(facesContext),
                    new FacesMessage(FacesMessage.SEVERITY_<WHATEVER>,
                    	"<messageSummary>", "<messageDetail>"));

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


On 9/9/05, Rick Reumann <ri...@gmail.com> wrote:
> I'm looking in the section of Core JSF on "messages" but I don't see
> how to create a typical "Your update of John Doe was Successful" type
> of message to be used on a JSP.
> 
> How do you accomplish this with JSF/MyFaces?
> 
> It seems like h:message and h:messages is really only geard for error
> type messages, but what about standard success type message?
> 
> Actually, I don't even see how to set up error messages. For example
> if I make a call to some backend procedure and want to display a
> failure message, how do I do this?
> 
> TIA,
> 
> --
> Rick
>