01: /**
02: * Copyright 2007 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.event.OnChangeEventListener;
19: import org.araneaframework.uilib.form.FormWidget;
20: import org.araneaframework.uilib.form.control.TextControl;
21: import org.araneaframework.uilib.form.control.inputfilter.InputFilter;
22: import org.araneaframework.uilib.form.data.StringData;
23:
24: /**
25: * @author Taimo Peelo (taimo@araneaframework.org)
26: */
27: public class FilteredInputDemoWidget extends TemplateBaseWidget {
28: private FormWidget form;
29:
30: /**
31: * Builds the form.
32: */
33: protected void init() throws Exception {
34: setViewSelector("demo/filteredInput");
35:
36: // creation of new form
37: form = new FormWidget();
38:
39: final InputFilter inputFilter = new InputFilter();
40:
41: final TextControl filter = new TextControl();
42: final TextControl filtered = new TextControl();
43: filtered.setInputFilter(inputFilter);
44: filter.addOnChangeEventListener(new OnChangeEventListener() {
45: public void onChange() throws Exception {
46: form.convert();
47: inputFilter.setCharacterFilter((String) form
48: .getValueByFullName("filter"));
49: form.setValueByFullName("filtered", null);
50: }
51: });
52:
53: form.addElement("filter", "demo.filteredinput.filterchars",
54: filter, new StringData(), false);
55: form.addElement("filtered", "demo.filteredinput.input",
56: filtered, new StringData(), false);
57:
58: // the usual, add the created widget to main widget.
59: addWidget("form", form);
60: }
61: }
|