chkal/pf-issue-test — Issue #87: MultiPageMessagesSupport duplicates messages with MyFaces 
Author: chkal
Created: 2012-03-06 07:31:39+00:00
State: open
Labels: Type-Defect

Originally filed by **chkalt** on 2011-02-10T16:28:59

Google Code issue: http://code.google.com/p/prettyfaces/issues/detail?id=89

Hey all,

the MultiPageMessagesSupport class does not play well with MyFaces. The problem is that the phase listener tries to remove the messages from the FacesContext after they have been saved. This works well with Mojarra because they return an iterator of the underlying list, but MyFaces doesn't. MyFaces implements the getMessages() methods in an immutable style. The spec doesn't contain any details about immutability. So it is unclear who is right in his way of implementation.

If the application is using MyFaces and an action methods returns null all messages will be shown twice. That happens because the messages are restored by our listener even if they were added (and not deleted) in the same request.

See:

http://ocpsoft.com/java/persist-and-pass-facesmessages-over-page-redirects/#comment-1288

I think one way to get rid of this problem would be to prevent the message restore if there are already messages in the context (see attached patch). I think there is no situation where it would make sense to restore messages while there are existing ones in the FacesContext queue.

What do you think? I want to make sure this patch doesn't break anything, so I'll put it into ReviewRequest state.