1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.lum.lu.ui.tools.client.widgets.itemlist; |
17 | |
|
18 | |
import java.util.List; |
19 | |
|
20 | |
import org.kuali.student.common.assembly.data.Data; |
21 | |
import org.kuali.student.common.assembly.data.QueryPath; |
22 | |
import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBindingSupport; |
23 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
24 | |
|
25 | 0 | public abstract class ItemListFieldBinding<V extends ItemValue<V>> extends ModelWidgetBindingSupport<ItemList<V>> { |
26 | |
|
27 | |
@Override |
28 | |
public void setModelValue(ItemList<V> widget, DataModel model, String path) { |
29 | 0 | QueryPath qPath = QueryPath.parse(path); |
30 | 0 | List<V> values = widget.getValue(); |
31 | 0 | Data valuesData = new Data(); |
32 | 0 | if (values != null) { |
33 | 0 | for (V val : values) { |
34 | 0 | Data valueData = new Data(); |
35 | 0 | setItemData(val, valueData); |
36 | 0 | valuesData.add(valueData); |
37 | 0 | } |
38 | |
} |
39 | 0 | model.set(qPath, valuesData); |
40 | 0 | } |
41 | |
|
42 | |
@Override |
43 | |
public void setWidgetValue(ItemList<V> widget, DataModel model, String path) { |
44 | 0 | QueryPath qPath = QueryPath.parse(path); |
45 | 0 | Data valueData = model.get(qPath); |
46 | 0 | List<V> values = null; |
47 | |
|
48 | 0 | if (valueData != null) { |
49 | 0 | values = getItemList(valueData); |
50 | 0 | widget.setValue(values); |
51 | |
} else { |
52 | 0 | widget.setValue(null); |
53 | |
} |
54 | 0 | } |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
public abstract void setItemData(V val, Data data); |
62 | |
|
63 | |
public abstract List<V> getItemList(Data data); |
64 | |
|
65 | |
} |