diff options
Diffstat (limited to 'src/com/itmill/toolkit/tests/book/TableExample.java')
-rw-r--r-- | src/com/itmill/toolkit/tests/book/TableExample.java | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/com/itmill/toolkit/tests/book/TableExample.java b/src/com/itmill/toolkit/tests/book/TableExample.java index 80c5dad3b0..4d888eaeae 100644 --- a/src/com/itmill/toolkit/tests/book/TableExample.java +++ b/src/com/itmill/toolkit/tests/book/TableExample.java @@ -26,22 +26,28 @@ public class TableExample extends CustomComponent { layout.addComponent(table); /* Define the names, data types, and default values of columns. */ - table.addContainerProperty("First Name", String.class, "(no first name)"); - table.addContainerProperty("Last Name", String.class, "(no last name)"); - table.addContainerProperty("Year", Integer.class, null); + table.addContainerProperty("First Name", String.class, + "(no first name)"); + table.addContainerProperty("Last Name", String.class, "(no last name)"); + table.addContainerProperty("Year", Integer.class, null); /* We use these entries to generate random items in a table. */ - final String[] firstnames = new String[] { "Donald", "Patty", "Sally", "Douglas" }; - final String[] lastnames = new String[] { "Smith", "Jones", "Adams", "Knuth" }; + final String[] firstnames = new String[] { "Donald", "Patty", "Sally", + "Douglas" }; + final String[] lastnames = new String[] { "Smith", "Jones", "Adams", + "Knuth" }; /* Add some items in the table and assign them an Item ID (IID). */ for (int i = 0; i < 1000; i++) { /* Add a randomly generated item in the Table. */ - table.addItem(new Object[] { - firstnames[(int) (Math.random() * (firstnames.length - 0.01))], - lastnames[(int) (Math.random() * (lastnames.length - 0.01))], - new Integer((int) (1900 + Math.random() * 100)) }, - new Integer(i)); + table + .addItem( + new Object[] { + firstnames[(int) (Math.random() * (firstnames.length - 0.01))], + lastnames[(int) (Math.random() * (lastnames.length - 0.01))], + new Integer( + (int) (1900 + Math.random() * 100)) }, + new Integer(i)); } /* Set the number of items visible in the table. */ @@ -53,17 +59,20 @@ public class TableExample extends CustomComponent { /* Allow selecting items from the table. */ table.setSelectable(true); - - /* When an item is selected, the selection is sent immediately to server. */ + + /* + * When an item is selected, the selection is sent immediately to + * server. + */ table.setImmediate(true); - + /* Handle selection change. */ table.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { current.setValue("Selected: " + table.getValue().toString()); } }); - + layout.addComponent(current); } } |