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.web.demo;
16:
17: import org.araneaframework.example.main.TemplateBaseWidget;
18: import org.araneaframework.uilib.form.FormWidget;
19: import org.araneaframework.uilib.form.control.SelectControl;
20: import org.araneaframework.uilib.form.data.StringData;
21: import org.araneaframework.uilib.support.DisplayItem;
22:
23: /**
24: * Demonstrates use of SelectControl rendered with radiobuttons.
25: *
26: * @author Taimo Peelo (taimo@araneaframework.org)
27: */
28: public class DemoRadioSelect extends TemplateBaseWidget {
29: private static final long serialVersionUID = 1L;
30: private FormWidget form;
31: private SelectControl control;
32:
33: protected void init() throws Exception {
34: setViewSelector("demo/demoRadioSelect");
35:
36: form = new FormWidget();
37:
38: control = new SelectControl();
39: control.addItem(new DisplayItem("1", "First"));
40: control.addItem(new DisplayItem("2", "Second"));
41: control.addItem(new DisplayItem("3", "Third"));
42: control.addItem(new DisplayItem("4", "Fourth"));
43: control.addItem(new DisplayItem("5", "Fifth"));
44:
45: form.addElement("select", "#Boring number", control,
46: new StringData(), false);
47: addWidget("form", form);
48: }
49:
50: public void handleEventTest(String param) throws Exception {
51: if (form.convertAndValidate()) {
52: String value = (String) form.getValueByFullName("select");
53: getMessageCtx().showInfoMessage(
54: value != null ? value : "null");
55: }
56: }
57: }
|