[
https://issues.apache.org/jira/browse/PB-80?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on PB-80 started by David Sean Taylor.
> FacesMessages are not displayed in the same order as they are added
> -------------------------------------------------------------------
>
> Key: PB-80
> URL: https://issues.apache.org/jira/browse/PB-80
> Project: Portals Bridges
> Issue Type: Bug
> Components: jsf
> Affects Versions: 1.0.3
> Environment: WebSphere Portal 6.0, MyFaces 1.1.5, Portals Bridges
> 1.0.3
> Reporter: Peter Bødskov
> Assignee: David Sean Taylor
> Fix For: 1.0.4
>
>
> In a BackingBean we have validation along the lines of this:
> if( ! validator.isTextValid(getText1())){
> FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "this is
> message no 1", "this is message no 1");
> getFacesContext().addMessage(compId, msg);
> }
> if( ! validator.isTextValid(getText2())){
> FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "this is
> message no 2", "this is message no 2");
> getFacesContext().addMessage(compId, msg);
> }
> if( ! validator.isTextValid(getText3())){
> FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "this is
> message no 3", "this is message no 3");
> getFacesContext().addMessage(compId, msg);
> }
> Where getText()1, getText2() and getText3() retireves the value of 3 text
> fields from a form.
> This results in 3 messages being added to FacesContext in the order:
> this is message no 1
> this is message no 2
> this is message no 3
> But, when these messages are displayed in a JSP page in a h:messages tag,
> they're displayed in this order:
> this is message no 3
> this is message no 2
> this is message no 1
> The reason for this is found in the saveFacesMessages method from the
> FacesPortlet
> if (msgs != null && msgs.hasNext()) {
> Map facesMsgs = new HashMap();
> ...
> ...
> session.setAttribute("FACES_MESSAGES", facesMsgs);
> When the HashMap facesMsgs is stored on the session, the order of the
> FacesMessage elemets in facesMsgs will be mixed. Therefore, when the messages
> are retrieved again in the method restoreFacesMessages, the order of the
> messages is no longer the same as when they was added from FacesContext to
> facesMsgs.
> I've tried replacing:
> Map facesMsgs = new HashMap();
> with
> Map facesMsgs = new LinkedHashMap();
> in saveFacesMessages, and that did the trick for me :-)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]