You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2004/04/25 04:58:43 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/action ActionMessages.java
husted 2004/04/24 19:58:43
Modified: src/share/org/apache/struts/action ActionMessages.java
Log:
Apply #27992 "FIFO ordering in ActionMessages" submitted by Haroon Rafique.
Revision Changes Path
1.19 +44 -7 jakarta-struts/src/share/org/apache/struts/action/ActionMessages.java
Index: ActionMessages.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMessages.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ActionMessages.java 14 Mar 2004 06:23:42 -0000 1.18
+++ ActionMessages.java 25 Apr 2004 02:58:43 -0000 1.19
@@ -140,7 +140,7 @@
if (item == null) {
list = new ArrayList();
- item = new ActionMessageItem(list, iCount++);
+ item = new ActionMessageItem(list, iCount++, property);
messages.put(property, item);
} else {
@@ -290,8 +290,28 @@
*/
public Iterator properties() {
- return this.messages.keySet().iterator();
+ if (messages.isEmpty()) {
+ return Collections.EMPTY_LIST.iterator();
+ }
+
+ ArrayList results = new ArrayList();
+ ArrayList actionItems = new ArrayList();
+ for (Iterator i = messages.values().iterator(); i.hasNext();) {
+ actionItems.add(i.next());
+ }
+
+ // Sort ActionMessageItems based on the initial order the
+ // property/key was added to ActionMessages.
+ Collections.sort(actionItems, actionItemComparator);
+
+ for (Iterator i = actionItems.iterator(); i.hasNext();) {
+ ActionMessageItem ami = (ActionMessageItem) i.next();
+ results.add(ami.getProperty());
+ }
+
+ return results.iterator();
+
}
@@ -357,9 +377,16 @@
protected int iOrder = 0;
- public ActionMessageItem(List list, int iOrder) {
+ /**
+ * <p>The property associated with <code>ActionMessage</code>.</p>
+ */
+ protected String property = null;
+
+
+ public ActionMessageItem(List list, int iOrder, String property) {
this.list = list;
this.iOrder = iOrder;
+ this.property = property;
}
@@ -380,6 +407,16 @@
public void setOrder(int iOrder) {
this.iOrder = iOrder;
+ }
+
+
+ public String getProperty() {
+ return property;
+ }
+
+
+ public void setProperty(String property) {
+ this.property = property;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org