001: package org.gridsphere.provider.portletui.beans;
002:
003: import org.gridsphere.portlet.service.spi.PortletServiceFactory;
004: import org.gridsphere.services.core.portal.PortalConfigService;
005:
006: /*
007: * @author <a href="mailto:wehrens@gridsphere.org">Oliver Wehrens</a>
008: * @version $Id: RichTextEditorBean.java 6385 2007-10-25 14:02:26Z wehrens $
009: */
010: public class RichTextEditorBean extends BaseComponentBean implements
011: TagBean {
012:
013: private int cols = 0;
014: private int rows = 0;
015: private String value = null;
016: private String action = null;
017:
018: /**
019: * Constructs a default text area bean
020: */
021: public RichTextEditorBean() {
022: super (TagBean.RICHTEXTEDITOR_NAME);
023: }
024:
025: /**
026: * Constructs a text area bean from a supplied portlet request and bean identifier
027: *
028: * @param beanId the bean identifier
029: */
030: public RichTextEditorBean(String beanId) {
031: super (TagBean.RICHTEXTEDITOR_NAME);
032: this .beanId = beanId;
033: }
034:
035: public String getAction() {
036: return action;
037: }
038:
039: public void setAction(String action) {
040: this .action = action;
041: }
042:
043: /**
044: * Gets the number of columns of the TextArea.
045: *
046: * @return number of columns
047: */
048: public int getCols() {
049: return cols;
050: }
051:
052: /**
053: * Sets the number of columns of the TextArea.
054: *
055: * @param cols number of cols
056: */
057: public void setCols(int cols) {
058: this .cols = cols;
059: }
060:
061: /**
062: * Return the number of rows of the textarea.
063: *
064: * @return number of rows
065: */
066: public int getRows() {
067: return rows;
068: }
069:
070: /**
071: * Sets the number of rows of the textarea.
072: *
073: * @param rows number of rows
074: */
075: public void setRows(int rows) {
076: this .rows = rows;
077: }
078:
079: /**
080: * Sets the bean value
081: *
082: * @param value the bean value
083: */
084: public void setValue(String value) {
085: this .value = value;
086: }
087:
088: /**
089: * Returns the bean value
090: *
091: * @return the bean value
092: */
093: public String getValue() {
094: return value;
095: }
096:
097: public String toStartString() {
098: PortalConfigService configService = (PortalConfigService) PortletServiceFactory
099: .createPortletService(PortalConfigService.class, true);
100: // deal with ROOT context case
101: String contextPath = configService
102: .getProperty("gridsphere.deploy");
103: if (!contextPath.equals(""))
104: contextPath = "/" + contextPath;
105: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
106: + "/javascript/tiny_mce/tiny_mce.js");
107: renderResponse.addProperty("JAVASCRIPT_SRC", contextPath
108: + "/javascript/tiny_mce/richtext.js");
109: StringBuffer sb = new StringBuffer();
110: String sname = createTagName(name);
111: sb.append("<textarea id=\"gridsphere-richtext\" name=\""
112: + sname + "\" cols=\"" + cols + "\" rows=\"" + rows
113: + "\">");
114: return sb.toString();
115: }
116:
117: public String toEndString() {
118: StringBuffer sb = new StringBuffer();
119: String result = (value != null) ? value : "";
120: sb.append(result + "</textarea>");
121: return sb.toString();
122: }
123: }
|