[ http://issues.apache.org/struts/browse/STR-2025?page=all ] David Evans closed STR-2025: ----------------------------
Resolution: Fixed > FIFO ordering in ActionMessages > ------------------------------- > > Key: STR-2025 > URL: http://issues.apache.org/struts/browse/STR-2025 > Project: Struts Action 1 > Type: Bug > Components: Action > Versions: Nightly Build > Environment: Operating System: other > Platform: Other > Reporter: Haroon Rafique > Assignee: David Evans > Fix For: 1.2 Family > Attachments: action_message_order.diff, action_message_order_niall.diff > > I had posted to the struts-user list at: > http://www.mail-archive.com/struts-user@jakarta.apache.org/msg97016.html > and struts-dev list at: > http://marc.theaimsgroup.com/?l=struts-dev&m=108031774812299&w=2 > I think I may have discovered a bug in > src/share/org/apache/struts/action/ActionMessages.java > ActionMessages are supposed to have FIFO ordering (as evidenced by the > presenence of property iOrder in the class ActionMessageItem). However, I > discovered a case whereby the ActionMessages would lose their order. > Let's say validator returned some errors (I'll only show property keys and > their > order): > {postalCode[Order=1],number[Order=0]} > As you can see they are in a weird order which is okay since its a HashMap and > order is not guaranteed. > Now, if I created another ActionErrors object with only 1 message: > {org.apache.struts.action.GLOBAL_MESSAGE[Order=0]} > and then tried to add using something like: > newErrors.add(oldErrors); > it would correclty keep the order and it would become something like: > > {postalCode[Order=1],org.apache.struts.action.GLOBAL_MESSAGE[Order=0],number[Order=2]} > So, struts is behaving correctly so far. It kept the order of the > GLOBAL_MESSAGE > 0 and created higher sequential order numbers for the other 2 added > properties. > However, unfortunately there are several other places later on in the struts > sequence where an empty ActionErrors object is combined with what was returned > from the validate() method. And this is where, automagically, the Order > numbers > start their sequencing all over again and become: > {postalCode[Order=0],org.apache.struts.action.GLOBAL_MESSAGE[Order=1],number[Order=2]} > The reason for this is that the properties() method only sends back an > iterator > to the unsorted HashMap. Instead it should send something back which is sorted > according to the order of the properties (similar to how its done in the get() > method). -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]