Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java @ 266:e3565f58b0ae
ISSUE-38 Set the first value of a select box as default value.
flys-client/trunk@1887 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 10 May 2011 16:25:00 +0000 |
parents | b92281182c6b |
children | 77234b1d009c |
comparison
equal
deleted
inserted
replaced
265:51f1c7420115 | 266:e3565f58b0ae |
---|---|
107 | 107 |
108 VLayout layout = new VLayout(); | 108 VLayout layout = new VLayout(); |
109 layout.setAlign(VerticalAlignment.TOP); | 109 layout.setAlign(VerticalAlignment.TOP); |
110 layout.setHeight(25); | 110 layout.setHeight(25); |
111 | 111 |
112 LinkedHashMap initial = new LinkedHashMap(); | |
113 | |
112 form = new DynamicForm(); | 114 form = new DynamicForm(); |
113 | 115 |
114 int size = data.size(); | 116 int size = data.size(); |
115 | 117 |
116 for (int i = 0; i < size; i++) { | 118 for (int i = 0; i < size; i++) { |
122 | 124 |
123 ComboBoxItem combobox = new ComboBoxItem(d.getLabel()); | 125 ComboBoxItem combobox = new ComboBoxItem(d.getLabel()); |
124 | 126 |
125 LinkedHashMap<String, String> it = new LinkedHashMap<String, String>(); | 127 LinkedHashMap<String, String> it = new LinkedHashMap<String, String>(); |
126 | 128 |
129 boolean firstItem = true; | |
130 | |
127 for (DataItem item: d.getItems()) { | 131 for (DataItem item: d.getItems()) { |
132 if (firstItem) { | |
133 initial.put(d.getLabel(), item.getStringValue()); | |
134 firstItem = false; | |
135 } | |
136 | |
128 it.put(item.getStringValue(), item.getLabel()); | 137 it.put(item.getStringValue(), item.getLabel()); |
129 } | 138 } |
130 | 139 |
131 label.setWidth(50); | 140 label.setWidth(50); |
132 combobox.setValueMap(it); | 141 combobox.setValueMap(it); |
134 form.setItems(combobox); | 143 form.setItems(combobox); |
135 | 144 |
136 layout.addMember(label); | 145 layout.addMember(label); |
137 layout.addMember(form); | 146 layout.addMember(form); |
138 } | 147 } |
148 | |
149 form.setValues(initial); | |
139 | 150 |
140 layout.setAlign(VerticalAlignment.TOP); | 151 layout.setAlign(VerticalAlignment.TOP); |
141 | 152 |
142 return layout; | 153 return layout; |
143 } | 154 } |