Issue Details (XML | Word | Printable)

Key: STR-1728
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Unassigned
Reporter: Quande Ren
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Struts 1

ActionMessages.getSortedProperties() needed

Created: 04/Sep/03 03:22 AM   Updated: 26/Nov/06 06:16 AM
Return to search
Component/s: Core, Tag Libraries
Affects Version/s: 1.1.0
Fix Version/s: None

Environment:
Operating System: other
Platform: Other

Bugzilla Id: 22912


 Description  « Hide
The <html:errors/> tag will output the standard error information, the error
order is defined by the order of properties in the validation.xml.

However, the <html:errors/> is not smart enough. I want to have my own error
output tag like <mytag:errors/>. I still want to keep the same order for the
properties. but the ActionMessages.properties() returns unsorted properties.
there's no way to get the sorted properties.

I suggest that we add another method called ActionMessages.getSortedProperties
(), the code can be like this:

  public Iterator getSortedProperties()
  {
    if(this.messages.isEmpty())
        return Collections.EMPTY_LIST.iterator();
      ArrayList keys = new ArrayList();

      for(Iterator i = this.messages.keySet().iterator(); i.hasNext(); ){
        keys.add(i.next());
      }

      Collections.sort(keys,new Comparator() {

        public int compare(Object o1, Object o2) {
          ActionMessageItem v1=(ActionMessageItem)messages.get(o1);
          ActionMessageItem v2=(ActionMessageItem)messages.get(o2);
          return v1.getOrder()-v2.getOrder();
        }

      });


      return keys.iterator();
  }

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no subversion log entries for this issue yet.