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: TryCatch.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.engine.testelements.continuations;
09:
10: import com.uwyn.rife.engine.Element;
11: import com.uwyn.rife.template.Template;
12:
13: public class TryCatch extends Element {
14: public void processElement() {
15: Template template = getHtmlTemplate("engine_continuation_trycatch");
16: try {
17: template.setValue("title", "start");
18: print(template);
19: pause();
20:
21: boolean do_throw = getParameterBoolean("throw", false);
22: if (do_throw) {
23: throw new RuntimeException(" : throw done");
24: }
25:
26: template.appendValue("title", " : throw not done");
27: print(template);
28: pause();
29: } catch (RuntimeException e) {
30: template.appendValue("title", e.getMessage());
31: template.appendValue("title", " catch");
32: print(template);
33: pause();
34: } finally {
35: template.appendValue("title", " : finally done");
36: print(template);
37: pause();
38: }
39:
40: template.appendValue("title", " : all done");
41: print(template);
42: }
43: }
|