01: /*
02: * $Id: AjaxCheckBox.java 461020 2006-06-12 19:52:36Z ivaynberg $ $Revision:
03: * 1.3 $ $Date: 2006-06-12 21:52:36 +0200 (Mon, 12 Jun 2006) $
04: *
05: * ==============================================================================
06: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
07: * use this file except in compliance with the License. You may obtain a copy of
08: * the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15: * License for the specific language governing permissions and limitations under
16: * the License.
17: */
18: package wicket.ajax.markup.html.form;
19:
20: import wicket.ajax.AjaxRequestTarget;
21: import wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
22: import wicket.markup.html.form.CheckBox;
23: import wicket.model.IModel;
24:
25: /**
26: * A CheckBox which is updated via ajax when the user changes its value
27: *
28: * @since 1.2
29: *
30: * @author Igor Vaynberg (ivaynberg)
31: */
32: public abstract class AjaxCheckBox extends CheckBox {
33: private static final long serialVersionUID = 1L;
34:
35: /**
36: * Construct.
37: *
38: * @param id
39: */
40: public AjaxCheckBox(final String id) {
41: this (id, null);
42: }
43:
44: /**
45: * Construct.
46: *
47: * @param id
48: * @param model
49: */
50: public AjaxCheckBox(final String id, final IModel model) {
51: super (id, model);
52:
53: setOutputMarkupId(true);
54:
55: add(new AjaxFormComponentUpdatingBehavior("onclick") {
56: private static final long serialVersionUID = 1L;
57:
58: protected void onUpdate(AjaxRequestTarget target) {
59: AjaxCheckBox.this .onUpdate(target);
60: }
61: });
62: }
63:
64: /**
65: * Listener method invoked on an ajax update call
66: *
67: * @param target
68: */
69: protected abstract void onUpdate(AjaxRequestTarget target);
70: }
|