01: package com.tctest.rife.elements;
02:
03: import com.uwyn.rife.engine.Element;
04: import com.uwyn.rife.engine.annotations.Elem;
05: import com.uwyn.rife.engine.annotations.ParamProperty;
06: import com.uwyn.rife.engine.annotations.Submission;
07: import com.uwyn.rife.template.Template;
08:
09: @Elem(submissions={@Submission(name="getanswer")})
10: public class StepBack extends Element {
11: private int mTotal = -5;
12: private boolean mStart = false;
13: private int mAnswer;
14:
15: @ParamProperty
16: public void setStart(boolean start) {
17: mStart = start;
18: }
19:
20: @ParamProperty
21: public void setAnswer(int answer) {
22: mAnswer = answer;
23: }
24:
25: public void processElement() {
26: Template template = getHtmlTemplate("stepback");
27:
28: if (mTotal < 0) {
29: mTotal++;
30: stepBack();
31: }
32:
33: template.setValue("stepback", duringStepBack());
34: print(template);
35: pause();
36:
37: if (mStart) {
38: template.setValue("subtotal", mTotal);
39: template.setValue("stepback", duringStepBack());
40: print(template);
41: pause();
42: mTotal += mAnswer;
43:
44: if (mTotal < 50) {
45: stepBack();
46: }
47: }
48:
49: template.setValue("subtotal", "got a total of " + mTotal);
50: template.setValue("stepback", duringStepBack());
51: print(template);
52: }
53: }
|