1
2
3
4
5 package oscon2006.web.mdb;
6
7 import java.util.Map;
8 import wicket.Component;
9 import wicket.extensions.markup.html.repeater.data.table.IColumn;
10 import wicket.extensions.markup.html.repeater.refreshing.Item;
11 import wicket.markup.html.basic.Label;
12 import wicket.model.IModel;
13
14 public class Column implements IColumn
15 {
16 private boolean sortable = false;
17 private String name;
18 private static final String CELL_ID = "cell";
19
20 public Column(String colName)
21 {
22 this.name = colName;
23 System.out.println("new Column instance: " + colName);
24 }
25
26 public Component getHeader(String id)
27 {
28 return new Label(id, this.getName().toUpperCase());
29 }
30
31 public String getSortProperty()
32 {
33 return null;
34 }
35
36 public void setSortable(boolean b)
37 {
38 this.sortable = b;
39 }
40
41 public boolean isSortable()
42 {
43 return this.sortable;
44 }
45
46 public String getName()
47 {
48 return this.name;
49 }
50
51 public void populateItem(Item item,
52 String componentId,
53 IModel rowModel)
54 {
55 int idx = item.getIndex();
56
57 Map<String, Object> rowData = (Map<String, Object>) rowModel.getObject(null);
58
59 String s = null;
60
61 if (rowData == null)
62 {
63 s = "";
64 }
65 else
66 {
67 Object value = rowData.get(this.getName());
68 s = String.valueOf(value);
69 }
70
71 item.add(new Label(CELL_ID, s));
72
73 }
74
75 public String toString()
76 {
77 return this.getName();
78 }
79
80 }