1 | |
package org.kuali.student.common.ui.client.configurable.mvc.binding; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.Iterator; |
5 | |
|
6 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
7 | |
import org.kuali.student.common.ui.client.widgets.ListOfStringWidget; |
8 | |
import org.kuali.student.core.assembly.data.Data; |
9 | |
import org.kuali.student.core.assembly.data.QueryPath; |
10 | |
import org.kuali.student.core.assembly.data.Data.DataValue; |
11 | |
import org.kuali.student.core.assembly.data.Data.Property; |
12 | |
|
13 | 0 | public class ListOfStringBinding implements ModelWidgetBinding<ListOfStringWidget> { |
14 | |
|
15 | |
@Override |
16 | |
public void setModelValue(ListOfStringWidget widget, DataModel model, String path) { |
17 | 0 | Data data = new Data(); |
18 | 0 | DataValue listData = new Data.DataValue(data); |
19 | 0 | for(String value:widget.getStringValues()){ |
20 | 0 | data.add(value); |
21 | |
} |
22 | 0 | model.set(QueryPath.parse(path), listData); |
23 | 0 | } |
24 | |
|
25 | |
@Override |
26 | |
public void setWidgetValue(ListOfStringWidget widget, DataModel model, String path) { |
27 | 0 | Data data = model.get(path); |
28 | 0 | ArrayList<String> values = new ArrayList<String>(); |
29 | 0 | if(data!=null){ |
30 | 0 | Iterator<Property> iter = data.realPropertyIterator(); |
31 | 0 | while(iter.hasNext()){ |
32 | 0 | Property prop = iter.next(); |
33 | 0 | String value = prop.getValue(); |
34 | 0 | values.add(value); |
35 | 0 | } |
36 | |
} |
37 | 0 | widget.setStringValues(values); |
38 | 0 | } |
39 | |
|
40 | |
} |