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
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 [EMAIL PROTECTED] 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
Re: How to setup and display non-error messages
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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
Yes! Put it up - the wiki is yours! regards, Martin On 9/9/05, Mike Kienenberger [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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
Yes, one has to kind of read between the lines using the standard books. On this particular question, the O'Reilly book goes over the summary and detail messages on pp. 126-127 (and warns about how to deal with single quotes in messages). It also explains how to selectively override standard messages. In Appendix D, it goes over how to override standard messages in more detail. On pp. 201-202, it goes over localization of messages. Core JavaServer Faces provides a downloadable utility class to make looking up message codes easier. The Javadoc at http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/tlddocs/index.html gives more detail about each individual attribute. Also, the book The J2EE Tutorial (2nd Edition, Addison Wesley) has a surprisingly detailed set of chapters on JSF in general (including messages). - Brendan -Original Message- From: Rick Reumann [mailto:[EMAIL PROTECTED] Sent: Friday, September 09, 2005 9:46 AM To: MyFaces Discussion Subject: Re: How to setup and display non-error messages 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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
FYI: The general concepts are explained on pp. 211 - 213 of Core JavaServer Faces. It allows you to specify the id of the component for which the message applies. - Brendan -Original Message- From: Mike Kienenberger [mailto:[EMAIL PROTECTED] Sent: Friday, September 09, 2005 10:21 AM To: MyFaces Discussion Subject: Re: How to setup and display non-error messages 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(facesC ontext), 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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