KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > communication > message > renderer > html > ViewMessageRenderer


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.communication.message.renderer.html;
6
7 import java.io.IOException JavaDoc;
8 import java.util.ResourceBundle JavaDoc;
9 import javax.faces.component.UIComponent;
10 import javax.faces.context.FacesContext;
11 import javax.faces.context.ResponseWriter;
12 import org.apache.commons.lang.StringUtils ;
13 import org.exoplatform.faces.core.renderer.html.*;
14 import org.exoplatform.portlets.communication.message.component.UIViewMessage;
15 import org.exoplatform.services.communication.message.Message;
16
17 /**
18  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
19  * @since Aug 27, 2004
20  * @version $Id: ViewMessageRenderer.java,v 1.7 2004/11/01 15:06:42 tuan08 Exp $
21  */

22 public class ViewMessageRenderer extends HtmlBasicRenderer {
23   public ViewMessageRenderer() {
24     buttonRenderer_ = new ThreeImagePatternButton("ic3-button", "ic3-select-button") ;
25   }
26   public void encodeChildren(FacesContext context, UIComponent component) throws IOException JavaDoc {
27     UIViewMessage uiView = (UIViewMessage) component;
28     ResponseWriter w = context.getResponseWriter();
29     ResourceBundle JavaDoc res = getApplicationResourceBundle(context.getExternalContext());
30     Message message = uiView.getMessage();
31     w.write("<table class='UIViewMessage'>");
32     w. write("<tr>");
33     w. write("<th>");
34     w. write("<label>"); w.write(res.getString("UIViewMessage.label.subject")); w.write("</label>");
35     w. write(ft_.format(message.getSubject()));
36     w. write("</th>");
37     w. write("</tr>");
38     w. write("<tr>");
39     w. write("<th>");
40     w. write("<label>");w.write(res.getString("UIViewMessage.label.from")); w.write("</label>");
41     w. write(ft_.format(message.getFrom()));
42     w. write("</th>");
43     w. write("</tr>");
44     w. write("<tr>");
45     w. write("<th>");
46     w. write("<label>"); w.write(res.getString("UIViewMessage.label.date")); w.write("</label>");
47     w. write(ft_.format(message.getReceivedDate()));
48     w. write("</th>");
49     w. write("</tr>");
50     w. write("<tr>");
51     w. write("<tr>");
52     w. write("<td class='actions'>");
53     buttonRenderer_.render(w, uiView, res.getString("UIViewMessage.button.view-as-html"),
54                            UIViewMessage.htmlFormatParams_);
55     buttonRenderer_.render(w, uiView, res.getString("UIViewMessage.button.view-as-text"),
56                            UIViewMessage.textFormatParams_);
57     w. write("</td>");
58     w. write("</tr>");
59     w. write("<td style='text-align: justify;'>");
60     String JavaDoc body = ft_.format(message.getBody()) ;
61     if(UIViewMessage.TEXT_FORMAT.equals(uiView.getFormat())) {
62       w. write("<pre>");
63       w. write(body);
64       w. write("</pre>");
65     } else {
66       body = StringUtils.replace(body, "\n","<br/>") ;
67       w. write(body);
68     }
69     w. write("</td>");
70     w. write("</tr>");
71     w. write("<tr>");
72     w. write("<td class='actions'>");
73     buttonRenderer_.render(w, uiView, res.getString("UIViewMessage.button.reply"),
74                            UIViewMessage.replyMessageParams_);
75     buttonRenderer_.render(w, uiView, res.getString("UIViewMessage.button.delete"),
76                            UIViewMessage.deleteMessageParams_);
77     buttonRenderer_.render(w, uiView, res.getString("UIViewMessage.button.archived"),
78                            UIViewMessage.archivedMessageParams_);
79     buttonRenderer_.render(w, uiView, res.getString("UIViewMessage.button.back"),
80                            UIViewMessage.cancelParams_);
81     w. write("</td>");
82     w. write("</tr>");
83     w.write("</table>");
84   }
85 }
Popular Tags