01: /*
02: #IFNDEF ALT_LICENSE
03: ThinWire(R) RIA Ajax Framework
04: Copyright (C) 2003-2007 Custom Credit Systems
05:
06: This library is free software; you can redistribute it and/or modify it under
07: the terms of the GNU Lesser General Public License as published by the Free
08: Software Foundation; either version 2.1 of the License, or (at your option) any
09: later version.
10:
11: This library is distributed in the hope that it will be useful, but WITHOUT ANY
12: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13: PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14:
15: You should have received a copy of the GNU Lesser General Public License along
16: with this library; if not, write to the Free Software Foundation, Inc., 59
17: Temple Place, Suite 330, Boston, MA 02111-1307 USA
18:
19: Users who would rather have a commercial license, warranty or support should
20: contact the following company who invented, built and supports the technology:
21:
22: Custom Credit Systems, Richardson, TX 75081, USA.
23: email: info@thinwire.com ph: +1 (888) 644-6405
24: http://www.thinwire.com
25: #ENDIF
26: [ v1.2_RC2 ]
27: */
28: package thinwire.render.web;
29:
30: import thinwire.ui.CheckBox;
31: import thinwire.ui.Component;
32: import thinwire.ui.event.PropertyChangeEvent;
33:
34: /**
35: * @author Joshua J. Gertzen
36: */
37: final class CheckBoxRenderer extends TextComponentRenderer {
38: private static final String CHECKBOX_CLASS = "tw_CheckBox";
39: private static final String SET_CHECKED = "setChecked";
40:
41: void render(WindowRenderer wr, Component c,
42: ComponentRenderer container) {
43: init(CHECKBOX_CLASS, wr, c, container);
44: CheckBox cb = (CheckBox) c;
45: addClientSideProperty(CheckBox.PROPERTY_CHECKED);
46: addInitProperty(CheckBox.PROPERTY_CHECKED, cb.isChecked());
47: super .render(wr, c, container);
48: }
49:
50: public void propertyChange(PropertyChangeEvent pce) {
51: String name = pce.getPropertyName();
52: if (isPropertyChangeIgnored(name))
53: return;
54: Object newValue = pce.getNewValue();
55:
56: if (name.equals(CheckBox.PROPERTY_CHECKED)) {
57: postClientEvent(SET_CHECKED, newValue);
58: } else {
59: super .propertyChange(pce);
60: }
61: }
62:
63: public void componentChange(WebComponentEvent event) {
64: String name = event.getName();
65: String value = (String) event.getValue();
66: CheckBox cb = (CheckBox) comp;
67:
68: if (name.equals(CheckBox.PROPERTY_CHECKED)) {
69: setPropertyChangeIgnored(CheckBox.PROPERTY_CHECKED, true);
70: cb.setChecked(Boolean.valueOf(value).booleanValue());
71: setPropertyChangeIgnored(CheckBox.PROPERTY_CHECKED, false);
72: } else {
73: super.componentChange(event);
74: }
75: }
76: }
|