001: /**
002: * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
003: * @version $Id: TextAreaTag.java 6401 2007-12-06 14:49:03Z wehrens $
004: */package org.gridsphere.provider.portletui.tags;
005:
006: import org.gridsphere.provider.portletui.beans.TextAreaBean;
007:
008: import javax.servlet.jsp.JspException;
009: import javax.servlet.jsp.JspWriter;
010:
011: /**
012: * A <code>TextAreaTag</code> represents a text area element
013: */
014: public class TextAreaTag extends InputTag {
015:
016: protected TextAreaBean textAreaBean = null;
017: protected int cols = 0;
018: protected int rows = 0;
019: protected String onFocus = null;
020:
021: /**
022: * Returns the number of columns of the text area
023: *
024: * @return number of columns
025: */
026: public int getCols() {
027: return cols;
028: }
029:
030: /**
031: * Sets the number of columns of the text area
032: *
033: * @param cols number of cols
034: */
035: public void setCols(int cols) {
036: this .cols = cols;
037: }
038:
039: /**
040: * Return the number of rows of the text area
041: *
042: * @return number of rows
043: */
044: public int getRows() {
045: return rows;
046: }
047:
048: /**
049: * Sets the number of rows of the text area
050: *
051: * @param rows number of rows
052: */
053: public void setRows(int rows) {
054: this .rows = rows;
055: }
056:
057: public void setOnfocus(String onFocus) {
058: this .onFocus = onFocus;
059: }
060:
061: public String getOnfocus() {
062: return onFocus;
063: }
064:
065: public int doStartTag() throws JspException {
066: if (!beanId.equals("")) {
067: textAreaBean = (TextAreaBean) getTagBean();
068: if (textAreaBean == null) {
069: textAreaBean = new TextAreaBean();
070: textAreaBean.setRows(rows);
071: textAreaBean.setCols(cols);
072: this .setBaseComponentBean(textAreaBean);
073: } else {
074: if ((textAreaBean.getCols() == 0) && (cols != 0)) {
075: textAreaBean.setCols(cols);
076: }
077: if ((textAreaBean.getRows() == 0) && (rows != 0)) {
078: textAreaBean.setRows(rows);
079: }
080: this .updateBaseComponentBean(textAreaBean);
081: }
082: } else {
083: textAreaBean = new TextAreaBean();
084: textAreaBean.setRows(rows);
085: textAreaBean.setCols(cols);
086: this .setBaseComponentBean(textAreaBean);
087: }
088:
089: if (onFocus != null)
090: textAreaBean.setOnFocus(onFocus);
091: if (onClick != null)
092: textAreaBean.setOnClick(onClick);
093: if (onChange != null)
094: textAreaBean.setOnChange(onChange);
095: if (onBlur != null)
096: textAreaBean.setOnBlur(onBlur);
097: if (onSelect != null)
098: textAreaBean.setOnSelect(onBlur);
099: if (cssClass != null)
100: textAreaBean.setCssClass(cssClass);
101: if (cssStyle != null)
102: textAreaBean.setCssStyle(cssStyle);
103: //debug();
104:
105: try {
106: JspWriter out = pageContext.getOut();
107: out.print(textAreaBean.toStartString());
108: } catch (Exception e) {
109: throw new JspException(e.getMessage());
110: }
111:
112: return EVAL_BODY_INCLUDE;
113: }
114:
115: public int doEndTag() throws JspException {
116:
117: if ((bodyContent != null) && (value == null)) {
118: textAreaBean.setValue(bodyContent.getString());
119: }
120:
121: try {
122: JspWriter out = pageContext.getOut();
123: out.print(textAreaBean.toEndString());
124: } catch (Exception e) {
125: throw new JspException(e.getMessage());
126: }
127:
128: super.release();
129: return EVAL_PAGE;
130: }
131:
132: }
|