001: /*
002: * (C) Copyright 2004 Nabh Information Systems, Inc.
003: *
004: * All copyright notices regarding Nabh's products MUST remain
005: * intact in the scripts and in the outputted HTML.
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public License
008: * as published by the Free Software Foundation; either version 2.1
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021: package com.nabhinc.portlet.mvcportlet.taglib;
022:
023: import javax.portlet.RenderRequest;
024: import javax.servlet.jsp.JspException;
025: import javax.servlet.jsp.JspWriter;
026:
027: import com.nabhinc.util.StringUtil;
028:
029: /**
030: * Displays an external HTML area defined by an iframe. Currently this tag is primarily used to
031: * display an HTML editor. The editor must be found in the defined path.
032: *
033: * @author Padmanabh Dabke
034: * (c) 2004 Nabh Information Systems, Inc. All Rights Reserved.
035: */
036: public class HtmlAreaTag extends BaseTag {
037: private String hatHeight = "200";
038: private String hatWidth = "600";
039: private String hatValue = null;
040: private String hatConfig = "";
041: private String hatToolbarSet = "MVCPortlet";
042: private String hatEditorPath = "/portlets/util/fckeditor/editor/fckeditor.html";
043:
044: public String getValue() {
045: return hatValue;
046: }
047:
048: public void setValue(String val) {
049: hatValue = val;
050: }
051:
052: public String getHeight() {
053: return hatHeight;
054: }
055:
056: public void setHeight(String ht) {
057: hatHeight = ht;
058: }
059:
060: public String getWidth() {
061: return hatWidth;
062: }
063:
064: public void setWidth(String w) {
065: hatWidth = w;
066: }
067:
068: public String getEditorPath() {
069: return hatEditorPath;
070: }
071:
072: public void setEditorPath(String ep) {
073: hatEditorPath = ep;
074: }
075:
076: public String getConfig() {
077: return hatConfig;
078: }
079:
080: public void setConfig(String c) {
081: hatConfig = c;
082: }
083:
084: public String getToolbarSet() {
085: return hatToolbarSet;
086: }
087:
088: public void setToolbarSet(String tbs) {
089: hatToolbarSet = tbs;
090: }
091:
092: public int doStartTag() throws JspException {
093:
094: try {
095: RenderRequest request = (RenderRequest) pageContext
096: .getRequest().getAttribute("javax.portlet.request");
097: JspWriter out = pageContext.getOut();
098: String fieldValue = null;
099:
100: if (hatValue == null) {
101: fieldValue = getParamValue(request);
102: if (fieldValue == null)
103: fieldValue = "";
104: } else {
105: fieldValue = hatValue;
106: }
107: String sLink = request.getContextPath() + hatEditorPath
108: + "?InstanceName=" + btName + "&Toolbar="
109: + hatToolbarSet;
110: String value = StringUtil.encodeHTML(fieldValue.replaceAll(
111: "'", "’"));
112: out.print("<div>");
113:
114: out.print("<input type=\"hidden\" id=\"");
115: out.print(btName);
116: out.print("\" name=\"");
117: out.print(btName);
118: out.print("\" value=\"");
119: out.print(value);
120: out.print("\" style=\"display:none\" />");
121:
122: out.print("<input type=\"hidden\" id=\"");
123: out.print(btName);
124: out.print("___Config\" value=\"");
125: out.print(hatConfig);
126: out.print("\" style=\"display:none\" />");
127:
128: out.print("<iframe id=\"");
129: out.print(btName);
130: out.print("___Frame\" src=\"");
131: out.print(sLink);
132: out.print("\" width=\"");
133: out.print(hatWidth);
134: out.print("\" height=\"");
135: out.print(hatHeight);
136: out.print("\" frameborder=\"0\" scrolling=\"no\" />");
137:
138: out
139: .print("<span>Editor does not work with Netscape 4 or Earlier and IE 5 or Earlier. Please upgrade your browser.</span>");
140: out.print("</iframe>");
141: out.print("</div>");
142:
143: } catch (Exception ex) {
144: throw new JspException(ex);
145: }
146:
147: return SKIP_BODY;
148: }
149:
150: public int doEndTag() {
151: return EVAL_PAGE;
152: }
153:
154: }
|