001: package org.gridsphere.provider.portletui.tags;
002:
003: import org.gridsphere.provider.portletui.beans.RichTextEditorBean;
004:
005: import javax.servlet.jsp.JspException;
006: import javax.servlet.jsp.JspWriter;
007:
008: /*
009: * @author <a href="mailto:wehrens@gridsphere.org">Oliver Wehrens</a>
010: * @version $Id: RichTextEditorTag.java 6385 2007-10-25 14:02:26Z wehrens $
011: */
012: public class RichTextEditorTag extends ActionTag {
013:
014: protected RichTextEditorBean textEditorBean = null;
015: private int cols = 0;
016: private int rows = 0;
017:
018: /**
019: * Returns the number of columns of the text area
020: *
021: * @return number of columns
022: */
023: public int getCols() {
024: return cols;
025: }
026:
027: /**
028: * Sets the number of columns of the text area
029: *
030: * @param cols number of cols
031: */
032: public void setCols(int cols) {
033: this .cols = cols;
034: }
035:
036: /**
037: * Return the number of rows of the text area
038: *
039: * @return number of rows
040: */
041: public int getRows() {
042: return rows;
043: }
044:
045: /**
046: * Sets the number of rows of the text area
047: *
048: * @param rows number of rows
049: */
050: public void setRows(int rows) {
051: this .rows = rows;
052: }
053:
054: public int doStartTag() throws JspException {
055: if (!beanId.equals("")) {
056: textEditorBean = (RichTextEditorBean) getTagBean();
057: if (textEditorBean == null) {
058: textEditorBean = new RichTextEditorBean();
059: textEditorBean.setRows(rows);
060: textEditorBean.setCols(cols);
061: this .setBaseComponentBean(textEditorBean);
062: } else {
063: if ((textEditorBean.getCols() == 0) && (cols != 0)) {
064: textEditorBean.setCols(cols);
065: }
066: if ((textEditorBean.getRows() == 0) && (rows != 0)) {
067: textEditorBean.setRows(rows);
068: }
069: this .updateBaseComponentBean(textEditorBean);
070:
071: }
072: } else {
073: textEditorBean = new RichTextEditorBean();
074: textEditorBean.setRows(rows);
075: textEditorBean.setCols(cols);
076: this .setBaseComponentBean(textEditorBean);
077: }
078:
079: textEditorBean.setAction(createActionURI());
080:
081: //debug();
082:
083: try {
084: JspWriter out = pageContext.getOut();
085: out.print(textEditorBean.toStartString());
086: } catch (Exception e) {
087: throw new JspException(e.getMessage());
088: }
089:
090: return EVAL_BODY_INCLUDE;
091: }
092:
093: public int doEndTag() throws JspException {
094:
095: if ((bodyContent != null) && (value == null)) {
096: textEditorBean.setValue(bodyContent.getString());
097: }
098:
099: try {
100: JspWriter out = pageContext.getOut();
101: out.print(textEditorBean.toEndString());
102: } catch (Exception e) {
103: throw new JspException(e.getMessage());
104: }
105: super.release();
106: return EVAL_PAGE;
107: }
108: }
|