-
1. Re: How can I clear facesMessages?
vasana May 6, 2008 4:48 PM (in response to cardel.ka.jelinek.seznam.cz)Do you have those messages defines in your Entity class?
-
2. Re: How can I clear facesMessages?
cardel.ka.jelinek.seznam.cz May 6, 2008 5:34 PM (in response to cardel.ka.jelinek.seznam.cz)I don´t understand You. Why should I have some messages in my entity class?
For example I have UserHome home object for my User entity. And in messages_en.properties I have messages User_created, User_updated, User_deleted. This messages are automatically showed if I make some changes on User entity and call UserHome.persist(), UserHome.update().
But In my case I have some action and in this action I am changing more objects. Finally I call UserHome.update(), FtpUserHome.update() ... So I have one message for every update and on the screen is:"User 'blabla' was updated" "Ftp user 'blabla' was updated"
But I want to clear all these messages on the end of my action a show only the last one, or show another one.
Thanks
-
3. Re: How can I clear facesMessages?
cardel.ka.jelinek.seznam.cz May 18, 2008 9:59 AM (in response to cardel.ka.jelinek.seznam.cz)Has anyone some tips?
-
4. Re: How can I clear facesMessages?
cardel.ka.jelinek.seznam.cz May 18, 2008 10:35 AM (in response to cardel.ka.jelinek.seznam.cz)I have debuged my code and I explored, this:
At the end of my action I have for example 3 messages
buffered in FacesMessages class, but they are not in facesMessages ArrayList which can be cleared by methods I wrote above, but my messages are in tasks ArrayList. I can browse them, when I am in debug mode, but I don't know how can I clear them.At the end of my action I return some outcome and then all of messages from tasks ArrayList are shown.
-
5. Re: How can I clear facesMessages?
stephen May 18, 2008 1:37 PM (in response to cardel.ka.jelinek.seznam.cz)RTM!
See section 12.2 Home Objects in the Seam reference.
The relevant text starts towards the end of the section withThe Home object automatically displays faces messages when an operation is successful.
-
6. Re: How can I clear facesMessages?
cardel.ka.jelinek.seznam.cz May 18, 2008 3:39 PM (in response to cardel.ka.jelinek.seznam.cz)I know about this feature. And I am using It. But I asked if it is possible to clear showed messages after persisting object via its Home Object.
-
7. Re: How can I clear facesMessages?
stephen May 18, 2008 10:34 PM (in response to cardel.ka.jelinek.seznam.cz)Then I just don't understand you.
You said you want to have the messages removed and I pointed you to a section that describes how you can disable them.
What am I missing?
-
8. Re: How can I clear facesMessages?
cardel.ka.jelinek.seznam.cz May 19, 2008 10:33 AM (in response to cardel.ka.jelinek.seznam.cz)No, I want to use this messages, but I want to remove some of showed messages, in some situation.
Example:
I call UserHome.persist() and message
User 'blabla' was created
is showed. It is ok.On other page I call CustomerHome.persist() and message
Customer 'blabla' was created
is showed. It is ok.But I have problem with this:
I call UserHome.persist() and CustomerHome.persist() in some action. And this shows me 2 messagesUser 'blabla' was created
andCustomer 'blabla' was created
. But I want to show only first one in this case. -
9. Re: How can I clear facesMessages?
turntwo Jun 12, 2008 10:59 PM (in response to cardel.ka.jelinek.seznam.cz)That doesn't help clear the messages when you don't want them. I have the same issue - I create several new records, but don't want the facesMessages showing in the UI. I tried to .clear() them, but to no avail.
-
10. Re: How can I clear facesMessages?
cardel.ka.jelinek.seznam.cz Jun 13, 2008 12:51 PM (in response to cardel.ka.jelinek.seznam.cz)I debugged my code and messages from home objects are stored in some buffer in tasks ArrayList in FacesMessages class. There is no method to clear this arraylist.
I have overrided problem messages User_created, User_updated, User_deleted so they are now empty. And I show my own message when I need. -
11. Re: How can I clear facesMessages?
leesy Jul 28, 2008 5:07 PM (in response to cardel.ka.jelinek.seznam.cz)I wanted to solve the same problem but taking a look through the Seam code, it looks like isn't something you can do from your Home bean. As you mentioned, when a message is created it goes into a list called
tasks
. This is a list of Runnable objects which on being run will take the task and add it to afacesMessages
list. The clear method clears this facesMessage list. So it looks like the items in the tasks list aren't being called till after the method in your home bean completes. So it looks like it's going to be a no go.What I plan on doing is override the Home classes persist() method and just do everything the home object does, minus the call to the createMessage() method.
-
12. Re: How can I clear facesMessages?
alesaudate Aug 28, 2008 4:17 PM (in response to cardel.ka.jelinek.seznam.cz)I was having the same trouble. After I read this forum, I produced a "hack", to get the tasks list and clear it. Below is the code:
try {
Field f = messages.getClass().getDeclaredField("tasks");
f.setAccessible(true);
List list = (List) f.get(messages);
list.clear();
}
catch (Exception e) {} -
13. Re: How can I clear facesMessages?
zahidncst Nov 12, 2008 1:11 AM (in response to cardel.ka.jelinek.seznam.cz)Above is a good hack..I may try it ..
I solved it byhiding
it with css style -visiblity:hidden
I detailed it at http://www.jroller.com/seam
-
14. Re: How can I clear facesMessages?
sinannn Mar 24, 2009 8:44 AM (in response to cardel.ka.jelinek.seznam.cz)There is a method named afterPhase() in facesMessages component. This method adds new messages to facesMessages' message list and then clear tasks list. If you firstly invoke facesMessages.afterPhase() method and after facesMessages.clear() method, nothing stays in message list.
Another trick is to use rich:messages component. There is a level property of this component and you can select which messages to be displayed by writing into level property WARN,FATAL etc. Surely, if you add your messages to facesMessages with a severity level.