01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/msgcntr/trunk/messageforums-app/src/java/org/sakaiproject/tool/messageforums/jsf/ShowAreaRender.java $
03: * $Id: ShowAreaRender.java 9227 2006-05-15 15:02:42Z cwen@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.tool.messageforums.jsf;
21:
22: import java.io.IOException;
23:
24: import javax.faces.component.UIComponent;
25: import javax.faces.context.FacesContext;
26: import javax.faces.context.ResponseWriter;
27: import javax.faces.render.Renderer;
28:
29: /**
30: * @author Chen Wen
31: * @version $Id$
32: */
33: public class ShowAreaRender extends Renderer {
34: public boolean supportsComponentType(UIComponent component) {
35: return (component instanceof ShowAreaComponent);
36: }
37:
38: public void encodeBegin(FacesContext context, UIComponent component)
39: throws IOException {
40: ResponseWriter writer = context.getResponseWriter();
41:
42: String value = (String) component.getAttributes().get("value");
43: String hideBorder = (String) component.getAttributes().get(
44: "hideBorder");
45: String showInputTextArea = (String) component.getAttributes()
46: .get("showInputTextArea");
47: if ((value != null) && (!value.equals(""))) {
48: int pos;
49: // writer.write("<div>");
50: value = value.replaceAll("<strong>", "<b>");
51: value = value.replaceAll("</strong>", "</b>");
52: // writer.write("<table STYLE=\"table-layout:fixed\" width=300><tr width=\"100%\"><td
53: // width=\"100%\" STYLE=\"word-wrap: break-all; white-space: -moz-pre-wrap;
54: // text-overflow:ellipsis; overflow: auto;\">");
55: value = value.replaceAll("<a title=",
56: "<a target=\"_new\" title=");
57: value = value
58: .replaceAll("<a href=",
59: "<a title=\"Open a new window\" target=\"_new\" href=");
60: if (hideBorder != null && hideBorder.equals("true")) {
61: writer.write("<div class=\"textPanel\">");
62: //gsilver .write("<table border=\"0\" id=\"message_table\" cellpadding=\"0\" width=\"90%\"><tr width=\"95%\"><td width=\"100%\" STYLE=\"word-wrap: break-word\">");
63:
64: writer.write(value);
65: writer.write("</div>");
66: } else if (showInputTextArea != null
67: && showInputTextArea.equals("true")) {
68: writer
69: .write("<textarea id=\"msgForum:forums:1:forum_extended_description\" name=\"msgForum:forums:1:forum_extended_description\" cols=\"100\" rows=\"5\" disabled=\"disabled\">");
70: writer.write(value);
71: writer.write("</textarea>");
72: } else {
73: writer.write("<div class=\"textPanel bordered\">");
74: // .write("<table border=\"1\" id=\"message_table\" cellpadding=\"7\" style=\"border-collapse: collapse; table-layout:fixed\" width=\"90%\"><tr width=\"95%\"><td width=\"100%\" STYLE=\"word-wrap: break-word\">");
75: writer.write(value);
76: writer.write("</div>");
77: }
78:
79: }
80: }
81:
82: public void encodeEnd(FacesContext context, UIComponent component)
83: throws IOException {
84: ResponseWriter writer = context.getResponseWriter();
85:
86: String value = (String) component.getAttributes().get("value");
87:
88: if ((value != null) && (!value.equals(""))) {
89: }
90: }
91: }
|