
| Key: |
STR-1728
|
| Type: |
Improvement
|
| Status: |
Open
|
| Priority: |
Minor
|
| Assignee: |
Unassigned
|
| Reporter: |
Quande Ren
|
| Votes: |
0
|
| Watchers: |
0
|
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
Operating System: other
Platform: Other
Operating System: other
Platform: Other
|
|
|
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();
}
|
|
Description
|
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();
} |
Show » |
|
ActionMessages (ie. <html:errors/>) should probably do the sorting instead.