File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes h:messages for components only. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "h:messages for components only." Watch "h:messages for components only." New topic
Author

h:messages for components only.

Oleg Varaksin
Greenhorn

Joined: Dec 10, 2009
Posts: 7
Hello,

How can I display messages releated to all components on a page (not global messages) with just one JSF tag? Is it possible?

I want to place such tag on the page top, but I don't need global messages.

Thanks in advance.
Oleg.
Sridhar Ponnusam
Greenhorn

Joined: Dec 16, 2009
Posts: 3
still you can use h:messages tag.
For example, How can I show a confirmation message after successfully persist data in database/ or a business validation message.

Java side code:
FacesContext context = FacesContext.getcurrentInstance();
context.addMessage(null, MessageUtils.getMessage(context, "Deatils saved successfully"); // we are passing component id as null here.

In UI:

<h:messages layout="table"/>

Dont specify "for" attribute here. It will show all the messages.
Oleg Varaksin
Greenhorn

Joined: Dec 10, 2009
Posts: 7
Hi,

But I don't want all messages. I want to dispaly only component related messages which were created with



And I want to do that with just one JSF tag. Well, I already know it doesn't work. I think, I must iterate over FacesConfig.getClientIdsWithMessages() and pass each Id into the h:message for-attribute.

Best regards.
Oleg.
Sridhar Ponnusam
Greenhorn

Joined: Dec 16, 2009
Posts: 3
ok. Did you try using "globalOnly" attribute of h:messages tag. true/false.



Oleg Varaksin
Greenhorn

Joined: Dec 10, 2009
Posts: 7
Yes, I tried it. It didn't help.
 
 
subject: h:messages for components only.