01: /*
02: * $Id: EffectsPage.java 461549 2006-07-25 12:53:12Z ehillenius $ $Revision: 461549 $
03: * $Date: 2006-07-25 14:53:12 +0200 (Tue, 25 Jul 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.examples.ajax.builtin;
19:
20: import wicket.ajax.AjaxRequestTarget;
21: import wicket.ajax.markup.html.AjaxFallbackLink;
22: import wicket.ajax.markup.html.AjaxLink;
23: import wicket.markup.html.basic.Label;
24: import wicket.model.PropertyModel;
25:
26: /**
27: * Demonstrates ajax effects
28: */
29: public class EffectsPage extends BasePage {
30: private int counter1 = 0;
31: private int counter2 = 0;
32:
33: /**
34: * @return Value of counter1
35: */
36: public int getCounter1() {
37: return counter1;
38: }
39:
40: /**
41: * @param counter1
42: * New value for counter1
43: */
44: public void setCounter1(int counter1) {
45: this .counter1 = counter1;
46: }
47:
48: /**
49: * @return Value for counter2
50: */
51: public int getCounter2() {
52: return counter2;
53: }
54:
55: /**
56: * @param counter2
57: * New value for counter2
58: */
59: public void setCounter2(int counter2) {
60: this .counter2 = counter2;
61: }
62:
63: /**
64: * Constructor
65: */
66: public EffectsPage() {
67: final Label c1 = new Label("c1", new PropertyModel(this ,
68: "counter1"));
69: c1.setOutputMarkupId(true);
70: add(c1);
71:
72: final Label c2 = new Label("c2", new PropertyModel(this ,
73: "counter2"));
74: c2.setOutputMarkupId(true);
75: add(c2);
76:
77: add(new AjaxLink("c1-link") {
78: public void onClick(AjaxRequestTarget target) {
79: counter1++;
80: target.addComponent(c1);
81: target.appendJavascript("new Effect.Shake($('"
82: + c1.getMarkupId() + "'));");
83: }
84: });
85:
86: add(new AjaxFallbackLink("c2-link") {
87: public void onClick(AjaxRequestTarget target) {
88: counter2++;
89: if (target != null) {
90: target.addComponent(c2);
91: target.appendJavascript("new Effect.Highlight($('"
92: + c2.getMarkupId() + "'));");
93: }
94: }
95:
96: });
97: }
98: }
|