01: /* Otherwise.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Tue Sep 6 15:33:38 2005, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2005 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.web.servlet.dsp.action;
20:
21: import java.io.IOException;
22:
23: import org.zkoss.web.mesg.MWeb;
24: import org.zkoss.web.servlet.ServletException;
25:
26: /**
27: * Represents the last alternative within a {@link Choose} action.
28: *
29: * @author tomyeh
30: */
31: public class Otherwise extends AbstractAction {
32: //-- Action --//
33: public void render(ActionContext ac, boolean nested)
34: throws javax.servlet.ServletException, IOException {
35: if (!nested && !isEffective())
36: return;
37:
38: final Action parent = ac.getParent();
39: if (!(parent instanceof Choose))
40: throw new ServletException(
41: "The parent of otherwise must be choose");
42: final Choose choose = (Choose) parent;
43: if (!choose.isMatched())
44: ac.renderFragment(null);
45: }
46:
47: //-- Object --//
48: public String toString() {
49: return "otherwise";
50: }
51: }
|