01: /* Remove.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Tue Sep 6 16:14:44 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: * The remove action used to remove an attribute.
28: *
29: * @author tomyeh
30: */
31: public class Remove extends AbstractAction {
32: private int _scope = ActionContext.PAGE_SCOPE;
33: private String _var;
34:
35: /** Returns the scope. */
36: public int getScope() {
37: return _scope;
38: }
39:
40: /** Sets the scope. */
41: public void setScope(String scope) {
42: _scope = toScope(scope);
43: }
44:
45: /** Returns the attribute name. */
46: public String getVar() {
47: return _var;
48: }
49:
50: /** Sets the attribute name. */
51: public void setVar(String var) {
52: _var = var;
53: }
54:
55: //-- Action --//
56: public void render(ActionContext ac, boolean nested)
57: throws javax.servlet.ServletException, IOException {
58: if (!isEffective())
59: return;
60: if (nested)
61: throw new ServletException(
62: MWeb.DSP_NESTED_ACTION_NOT_ALLOWED, new Object[] {
63: this , new Integer(ac.getLineNumber()) });
64: if (_var == null)
65: throw new ServletException(MWeb.DSP_ATTRIBUTE_REQUIRED,
66: new Object[] { this , "var",
67: new Integer(ac.getLineNumber()) });
68: ac.removeAttribute(_var, _scope);
69: }
70:
71: //-- Object --//
72: public String toString() {
73: return "remove";
74: }
75: }
|