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();
}