01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.example.main.release.features;
16:
17: import java.util.ArrayList;
18: import java.util.List;
19: import java.util.Locale;
20: import java.util.Random;
21: import org.apache.commons.logging.Log;
22: import org.apache.commons.logging.LogFactory;
23: import org.araneaframework.example.main.TemplateBaseWidget;
24: import org.araneaframework.example.main.business.util.TestVO;
25: import org.araneaframework.uilib.list.BeanListWidget;
26: import org.araneaframework.uilib.list.ListWidget;
27: import org.araneaframework.uilib.list.dataprovider.MemoryBasedListDataProvider;
28:
29: /**
30: * This is an example of component with a single list.
31: */
32: public class SimpleListWidget extends TemplateBaseWidget {
33: private static final long serialVersionUID = 1L;
34:
35: private static final Log log = LogFactory
36: .getLog(SimpleListWidget.class);
37:
38: protected ListWidget simpleList;
39:
40: protected void init() throws Exception {
41: setViewSelector("release/features/simpleList");
42:
43: simpleList = new BeanListWidget(TestVO.class);
44: addWidget("simpleList", simpleList);
45: simpleList.setDataProvider(new SimpleListDataProvider());
46: simpleList.setOrderableByDefault(true);
47: simpleList.addField("booleanValue", "#Boolean");
48: simpleList.addField("stringValue", "#String");
49: simpleList.addField("longValue", "#Long");
50: simpleList.setInitialOrder("longValue", true);
51: }
52:
53: private static class SimpleListDataProvider extends
54: MemoryBasedListDataProvider {
55: private static final long serialVersionUID = 1L;
56: protected List data = new ArrayList();
57:
58: public SimpleListDataProvider() {
59: super (TestVO.class);
60: Random rnd = new Random();
61:
62: for (int i = 0; i < 100; i++) {
63: TestVO test1 = new TestVO();
64: test1.setId(new Long(1 + i));
65: test1.setBooleanValue(Boolean.TRUE);
66:
67: test1.setStringValue(new Locale("en", Locale
68: .getISOCountries()[i])
69: .getDisplayCountry(Locale.ENGLISH));
70: test1.setLongValue(new Long(rnd.nextLong() % 100));
71: data.add(test1);
72:
73: TestVO test2 = new TestVO();
74: test2.setId(new Long(2 + i));
75: test2.setBooleanValue(Boolean.TRUE);
76: test2.setStringValue("Peculiar");
77: test2.setLongValue(new Long(rnd.nextLong() % 100));
78: data.add(test2);
79:
80: TestVO test3 = new TestVO();
81: test3.setId(new Long(3 + i));
82: test3.setBooleanValue(Boolean.FALSE);
83: test3.setStringValue("Queer");
84: test3.setLongValue(new Long(rnd.nextLong() % 100));
85: data.add(test3);
86: }
87: }
88:
89: public List loadData() {
90: return data;
91: }
92: }
93:
94: public void handleEventReturn(String eventParameter)
95: throws Exception {
96: getFlowCtx().cancel();
97: }
98: }
|