001: /**
002: * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
003: * @version $Id: TableCellTag.java 6385 2007-10-25 14:02:26Z wehrens $
004: */package org.gridsphere.provider.portletui.tags;
005:
006: import org.gridsphere.provider.portletui.beans.TableCellBean;
007:
008: import javax.servlet.jsp.JspException;
009: import javax.servlet.jsp.JspWriter;
010:
011: /**
012: * A <code>TableCellTag</code> represents a table cell element contained by a <code>TableRowTag</code>
013: */
014: public class TableCellTag extends BaseComponentTag {
015:
016: protected TableCellBean cellBean = null;
017: protected String width = null;
018: protected String height = null;
019: protected String align = null;
020: protected String valign = null;
021: protected String rowspan = null;
022: protected String colspan = null;
023:
024: /**
025: * Sets the table alignment e.g. "left", "center" or "right"
026: *
027: * @param align the table alignment
028: */
029: public void setAlign(String align) {
030: this .align = align;
031: }
032:
033: /**
034: * Returns the table alignment e.g. "left", "center" or "right"
035: *
036: * @return the table alignment
037: */
038: public String getAlign() {
039: return align;
040: }
041:
042: /**
043: * Sets the table vertical alignment e.g. "top", "middle", "bottom" or "baseline"
044: *
045: * @param valign the table vertical alignment
046: */
047: public void setValign(String valign) {
048: this .valign = valign;
049: }
050:
051: /**
052: * Returns the table vertical alignment e.g. "top", "middle", "bottom" or "baseline"
053: *
054: * @return the table vertical alignment
055: */
056: public String getValign() {
057: return valign;
058: }
059:
060: /**
061: * Sets the table cell width
062: *
063: * @param width the table cell width
064: */
065: public void setWidth(String width) {
066: this .width = width;
067: }
068:
069: /**
070: * Returns the table cell width
071: *
072: * @return the table cell width
073: */
074: public String getWidth() {
075: return width;
076: }
077:
078: /**
079: * Sets the table cell height
080: *
081: * @param height the table cell height
082: */
083: public void setHeight(String height) {
084: this .height = height;
085: }
086:
087: /**
088: * Returns the table cell height
089: *
090: * @return the table cell height
091: */
092: public String getHeight() {
093: return height;
094: }
095:
096: /**
097: * Returns the table cell row span
098: *
099: * @return the table cell row span
100: */
101: public String getRowspan() {
102: return rowspan;
103: }
104:
105: /**
106: * Sets the table cell row span
107: *
108: * @param rowspan the table cell row span
109: */
110: public void setRowspan(String rowspan) {
111: this .rowspan = rowspan;
112: }
113:
114: /**
115: * Returns the table cell col span
116: *
117: * @return the table cell col span
118: */
119: public String getColspan() {
120: return colspan;
121: }
122:
123: /**
124: * Sets the table cell col span
125: *
126: * @param colspan the table cell col span
127: */
128: public void setColspan(String colspan) {
129: this .colspan = colspan;
130: }
131:
132: /**
133: * Sets the table cell bean
134: *
135: * @param cellBean the table cell bean
136: */
137: public void setCellBean(TableCellBean cellBean) {
138: this .cellBean = cellBean;
139: }
140:
141: /**
142: * Returns the table cell bean
143: *
144: * @return the table cell bean
145: */
146: public TableCellBean getCellBean() {
147: return cellBean;
148: }
149:
150: public void release() {
151: cellBean = null;
152: width = null;
153: height = null;
154: align = null;
155: valign = null;
156: super .release();
157: }
158:
159: public int doStartTag() throws JspException {
160: if (!beanId.equals("")) {
161: cellBean = (TableCellBean) getTagBean();
162: if (cellBean == null)
163: cellBean = new TableCellBean();
164: } else {
165: cellBean = new TableCellBean();
166: if (width != null)
167: cellBean.setWidth(width);
168: if (height != null)
169: cellBean.setHeight(height);
170: if (align != null)
171: cellBean.setAlign(align);
172: if (valign != null)
173: cellBean.setValign(valign);
174: if (rowspan != null)
175: cellBean.setRowspan(rowspan);
176: if (colspan != null)
177: cellBean.setColspan(colspan);
178: if (cssClass != null)
179: cellBean.setCssClass(cssClass);
180: if (cssStyle != null)
181: cellBean.setCssStyle(cssStyle);
182: }
183: /*
184: TableRowTag rowTag = (TableRowTag) getParent();
185: if (rowTag.getHeader()) {
186: cellBean.setCssClass(TableRowBean.TABLE_HEADER_STYLE);
187: } else if (rowTag.getZebra()) {
188: cellBean.setCssClass(TableRowBean.TABLE_ALTERNATE_STYLE);
189: }
190: */
191: try {
192: JspWriter out = pageContext.getOut();
193: out.print(cellBean.toStartString());
194: } catch (Exception e) {
195: throw new JspException(e);
196: }
197: return EVAL_BODY_INCLUDE;
198: }
199:
200: public int doEndTag() throws JspException {
201:
202: try {
203: JspWriter out = pageContext.getOut();
204: out.print(cellBean.toEndString());
205: } catch (Exception e) {
206: throw new JspException(e);
207: }
208: super.doEndTag();
209: return EVAL_PAGE;
210: }
211: }
|