01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: Counter.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.engine.testelements.embedding.embedded;
09:
10: import com.uwyn.rife.engine.Element;
11: import com.uwyn.rife.engine.annotations.Elem;
12: import com.uwyn.rife.engine.annotations.InputProperty;
13: import com.uwyn.rife.engine.annotations.OutputProperty;
14: import com.uwyn.rife.engine.annotations.SubmissionHandler;
15: import com.uwyn.rife.template.Template;
16:
17: @Elem(url="")
18: public class Counter extends Element {
19: private int counter = 0;
20:
21: @InputProperty
22: public void setCounter(int counter) {
23: this .counter = counter;
24: }
25:
26: @OutputProperty
27: public int getCounter() {
28: return counter;
29: }
30:
31: @SubmissionHandler
32: public void doDecrease() {
33: counter--;
34: processElement();
35: }
36:
37: @SubmissionHandler
38: public void doIncrease() {
39: counter++;
40: processElement();
41: }
42:
43: public void processElement() {
44: Template t = getHtmlTemplate("engine_embedding_counter");
45: t.setValue("counternumber", getEmbedDifferentiator());
46: t.setValue("counter", counter);
47: print(t);
48: }
49: }
|