changeset 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 51f1c7420115
children 7e484390d191
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java
diffstat 2 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue May 10 16:13:16 2011 +0000
+++ b/flys-client/ChangeLog	Tue May 10 16:25:00 2011 +0000
@@ -1,3 +1,10 @@
+2011-05-10  Ingo Weinzierl <ingo@intevation.de>
+
+	  ISSUE-38
+
+	* src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java:
+	  Set the first value of a select box as default value.
+
 2011-05-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/FLYSConstants.properties,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java	Tue May 10 16:13:16 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java	Tue May 10 16:25:00 2011 +0000
@@ -109,6 +109,8 @@
         layout.setAlign(VerticalAlignment.TOP);
         layout.setHeight(25);
 
+        LinkedHashMap initial = new LinkedHashMap();
+
         form = new DynamicForm();
 
         int size = data.size();
@@ -124,7 +126,14 @@
 
             LinkedHashMap<String, String> it = new LinkedHashMap<String, String>();
 
+            boolean firstItem = true;
+
             for (DataItem item: d.getItems()) {
+                if (firstItem) {
+                    initial.put(d.getLabel(), item.getStringValue());
+                    firstItem = false;
+                }
+
                 it.put(item.getStringValue(), item.getLabel());
             }
 
@@ -137,6 +146,8 @@
             layout.addMember(form);
         }
 
+        form.setValues(initial);
+
         layout.setAlign(VerticalAlignment.TOP);
 
         return layout;

http://dive4elements.wald.intevation.org