Hello,
In FF and IE6 the drop down in the select items shows the expected order, however in Chrome (v2 and v3) it does not.
A debug string is printed out which shows the expected order, which makes me believe it is not a GWT issue.
Case:
The valueMap here is sorted on value, rather than on key.
But in Chrome the valueMap is sorted on key.
tested on SmartGWT build 815
In FF and IE6 the drop down in the select items shows the expected order, however in Chrome (v2 and v3) it does not.
A debug string is printed out which shows the expected order, which makes me believe it is not a GWT issue.
Case:
The valueMap here is sorted on value, rather than on key.
But in Chrome the valueMap is sorted on key.
tested on SmartGWT build 815
Code:
private Canvas getSortingTestSC() { VLayout layout = new VLayout(); DynamicForm form = new DynamicForm(); SelectItem select = new SelectItem("value"); SortedSet<SomeObject> sortMeFirst = new TreeSet<SomeObject>(); sortMeFirst.add(new SomeObject("9", "AAA")); sortMeFirst.add(new SomeObject("1", "ZZZ")); sortMeFirst.add(new SomeObject("5", "NNN")); StringBuffer sb = new StringBuffer(); LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(); for (SomeObject obj : sortMeFirst) { valueMap.put(obj.getKey(), obj.getValue()); sb.append(obj.getKey()).append("=").append(obj.getValue()).append(", "); } //expected result after sort: AAA, NNN, ZZZ select.setValueMap(valueMap); form.setFields(select); layout.addMember(form); //string contains correct order, selectItem does not show correct order in Chrome //IE, FF are fine SC.say(sb.toString()); return layout; } private class SomeObject implements Serializable, Comparable<SomeObject> { private static final long serialVersionUID = 1L; private String key; private String value; public SomeObject(String key, String value) { this.key = key; this.value = value; } public void setKey(String key) { this.key = key; } public String getKey() { return key; } public void setValue(String value) { this.value = value; } public String getValue() { return value; } public int compareTo(SomeObject o) { return this.getValue().compareTo(o.getValue()); } }
Comment