001: /* Box.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Fri Sep 16 13:59:54 2005, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2005 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.web.servlet.dsp.action.html;
020:
021: import java.util.Map;
022: import java.util.HashMap;
023: import java.io.IOException;
024:
025: import org.zkoss.web.mesg.MWeb;
026: import org.zkoss.web.servlet.ServletException;
027: import org.zkoss.web.servlet.http.Encodes;
028: import org.zkoss.web.servlet.dsp.action.AbstractAction;
029: import org.zkoss.web.servlet.dsp.action.ActionContext;
030:
031: /**
032: * Generates a box that has a caption and a border enclosing other tags.
033: *
034: * @author tomyeh
035: */
036: public class Box extends AbstractAction {
037: private String _align;
038: private String _color = "black";
039: private String _spacing = "3";
040: private String _width = "100%";
041: private String _caption;
042: private boolean _shadow = false;
043:
044: /** Returns the horizontal alignment.
045: * Default: null.
046: */
047: public String getAlign() {
048: return _align;
049: }
050:
051: /** Sets the horizontal alignment.
052: */
053: public void setAlign(String align) {
054: _align = align;
055: }
056:
057: /** Returns the color.
058: * Default: black.
059: */
060: public String getColor() {
061: return _color;
062: }
063:
064: /** Sets the color.
065: * <p>You might use any string that HTML supports.
066: */
067: public void setColor(String color) {
068: _color = color;
069: }
070:
071: /** Returns whether this box has the shadow effect.
072: * Default: false.
073: */
074: public boolean isShadow() {
075: return _shadow;
076: }
077:
078: /** Sets whether this box has the shadow effect.
079: */
080: public void setShadow(boolean shadow) {
081: _shadow = shadow;
082: }
083:
084: /** Returns the spacing.
085: * Default: 3.
086: */
087: public String getSpacing() {
088: return _spacing;
089: }
090:
091: /** Sets the spacing.
092: */
093: public void setSpacing(String spacing) {
094: _spacing = spacing;
095: }
096:
097: /** Returns the width.
098: * Default: 100%.
099: */
100: public String getWidth() {
101: return _width;
102: }
103:
104: /** Sets the width.
105: */
106: public void setWidth(String width) {
107: _width = width;
108: }
109:
110: /** Returns the caption.
111: * Default: null (no caption at all).
112: */
113: public String getCaption() {
114: return _caption;
115: }
116:
117: /** Sets the caption.
118: */
119: public void setCaption(String caption) {
120: _caption = caption;
121: }
122:
123: public void render(ActionContext ac, boolean nested)
124: throws javax.servlet.ServletException, IOException {
125: if (!isEffective())
126: return;
127:
128: final Map attrs = new HashMap();
129: put(attrs, "align", _align);
130: put(attrs, "color", _color);
131: put(attrs, "shadow", _shadow);
132: put(attrs, "spacing", _spacing);
133: put(attrs, "caption", _caption);
134: put(attrs, "width", _width);
135: put(attrs, "actionContext", ac);
136:
137: ac.include("~./dsp/action/html/box.dsp", attrs);
138: }
139:
140: //-- Object --//
141: public String toString() {
142: return "box";
143: }
144: }
|