KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.* ;
8 import java.io.IOException JavaDoc;
9 import javax.faces.component.UIComponent;
10 import javax.faces.context.FacesContext;
11 import javax.faces.context.ResponseWriter;
12 import org.exoplatform.faces.core.component.model.Parameter;
13 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer;
14 import org.exoplatform.portlets.communication.message.component.*;
15 import org.exoplatform.services.communication.message.*;
16 /**
17  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
18  * @since Aug 27, 2004
19  * @version $Id: AccountConfigurationRenderer.java,v 1.6 2004/11/03 01:24:56 tuan08 Exp $
20  */

21 public class AccountConfigurationRenderer extends HtmlBasicRenderer {
22   
23   public void encodeChildren(FacesContext context, UIComponent component ) throws IOException JavaDoc {
24     UIAccountConfiguration uiAccConfig = (UIAccountConfiguration) component ;
25     List accounts = uiAccConfig.getAccounts() ;
26     ResponseWriter w = context.getResponseWriter() ;
27     ResourceBundle res = getApplicationResourceBundle(context.getExternalContext());
28     w.write("<table class='UIAccountConfiguration'>") ;
29     w. write("<tr>") ;
30     w. write("<th colspan='2'>") ;
31     w. write(res.getString("UIAccountConfiguration.header.account-configuration")) ;
32     w. write("</th>") ;
33     w. write("<tr>") ;
34     w. write("<tr>") ;
35     w. write("<td>") ;
36     w. write("<h6>") ;
37     w. write(res.getString("UIAccountConfiguration.header.your-accounts")) ;
38     w. write("</h6>") ;
39     w. write("<div>") ;
40     w. write(res.getString("UIAccountConfiguration.info.account-configuration")) ;
41     w. write("</div>") ;
42     w. write("<ul>") ;
43     Parameter accountNameParam = new Parameter(UIAccountConfiguration.ACCOUNT_NAME, "") ;
44     Parameter[] selectAccountParams =
45       {UIAccountConfiguration.selectAccountParam, accountNameParam } ;
46     for(int i = 0 ; i < accounts.size(); i++) {
47       Account account = (Account) accounts.get(i) ;
48       accountNameParam.setValue(account.getAccountName()) ;
49       w. write("<li>") ;
50       linkRenderer_.render(w, uiAccConfig, account.getAccountName(), selectAccountParams);
51       w. write("</li>") ;
52     }
53     w. write("</ul>") ;
54     w. write("<div>") ;
55     linkRenderer_.render(w, uiAccConfig, res.getString("UIAccountConfiguration.button.add-account"),
56                          UIAccountConfiguration.addAccountParams_);
57     w. write("</div>") ;
58     w. write("</td>") ;
59     w. write("<td>") ;
60     renderSelectAccount(w, uiAccConfig, res) ;
61     w. write("</td>") ;
62     w. write("</tr>") ;
63     w.write("</table>") ;
64   }
65       
66   private void renderSelectAccount(ResponseWriter w, UIAccountConfiguration uiAccConfig,
67                                   ResourceBundle res) throws IOException JavaDoc {
68     Account account = uiAccConfig.getSelectAccount() ;
69     w.write("<h6>") ;
70     w. write(res.getString("UIAccountConfiguration.header.account-information")) ;
71     w.write("</h6>") ;
72     if(account == null) {
73       w.write("<div>") ;
74       w. write(res.getString("UIAccountConfiguration.info.no-account")) ;
75       w.write("</div>") ;
76       return ;
77     }
78     w.write("<table class='account-detail'>") ;
79     w. write("<tr>") ;
80     w. write("<td><label>");
81     w. write(res.getString("UIAccountConfiguration.label.account-name"));
82     w. write("</label></td>") ;
83     w. write("<td>"); w.write(account.getAccountName()); w.write("</td>") ;
84     w. write("</tr>") ;
85     w. write("<td><label>");
86     w. write(res.getString("UIAccountConfiguration.label.account-owner"));
87     w. write("</label></td>") ;
88     w. write("<td>"); w.write(account.getOwner()); w.write("</td>") ;
89     w. write("</tr>") ;
90     w. write("</tr>") ;
91     w. write("<td><label>");
92     w. write(res.getString("UIAccountConfiguration.label.owner-name"));
93     w. write("</label></td>") ;
94     w. write("<td>"); w.write(ft_.format(account.getOwnerName())); w.write("</td>") ;
95     w. write("</tr>") ;
96     w. write("</tr>") ;
97     w. write("<td><label>");
98     w. write(res.getString("UIAccountConfiguration.label.reply-to"));
99     w. write("</label></td>") ;
100     w. write("<td>"); w.write(ft_.format(account.getReplyToAddress())); w.write("</td>") ;
101     w. write("</tr>") ;
102     w. write("<tr>") ;
103     w. write("<td><label>");
104     w. write(res.getString("UIAccountConfiguration.label.message-protocol"));
105     w. write("</label></td>") ;
106     w. write("<td>") ; w.write(account.getProtocol()); w.write("</td>") ;
107     w. write("</tr>") ;
108     if(!MessageService.STANDALONE_PROTOCOL.equals(account.getProtocol())) {
109       w.write("<tr>") ;
110       w. write("<td><label>");
111       w. write(res.getString("UIAccountConfiguration.label.user-name"));
112       w. write("</label></td>") ;
113       w. write("<td>") ;
114       w. write(ft_.format(account.getProperty(Account.SERVER_SETTING_USERNAME)));
115       w. write("</td>") ;
116       w.write("</tr>") ;
117       w.write("<tr>") ;
118       w. write("<td><label>");
119       w. write(res.getString("UIAccountConfiguration.label.password"));
120       w. write("</label></td>") ;
121       w. write("<td>") ;
122       w. write(ft_.format(account.getProperty(Account.SERVER_SETTING_PASSWORD)));
123       w. write("</td>") ;
124       w.write("</tr>") ;
125       w.write("<tr>") ;
126       w. write("<td><label>");
127       w. write(res.getString("UIAccountConfiguration.label.mail-server"));
128       w. write("</label></td>") ;
129       w. write("<td>") ;
130       w. write(ft_.format(account.getProperty(Account.SERVER_SETTING_HOSTNAME)));
131       w. write("</td>") ;
132       w.write("</tr>") ;
133     }
134     w. write("<tr>") ;
135     w. write("<td colspan='2'>");
136     w. write(res.getString("UIAccountConfiguration.label.message-boxes"));
137     List folders = uiAccConfig.getSelectAccountFolders() ;
138     Parameter folderNameParam = new Parameter(UIAccountConfiguration.FOLDER_NAME, "") ;
139     Parameter[] selectFolderParams =
140       {UIAccountConfiguration.selectFolderParam, folderNameParam } ;
141     w.write("<ul>") ;
142     for(int i = 0; i < folders.size(); i++) {
143       Folder folder = (Folder) folders.get(i) ;
144       folderNameParam.setValue(folder.getName()) ;
145       w.write("<li>") ;
146       linkRenderer_.render(w, uiAccConfig, folder.getLabel(), selectFolderParams);
147       w.write("</li>") ;
148     }
149     w. write("<li>") ;
150     linkRenderer_.render(w, uiAccConfig, res.getString("UIAccountConfiguration.button.add-folder"),
151                          UIAccountConfiguration.addFolderParams_);
152     w. write("</li>") ;
153     w.write("</ul>") ;
154     w. write("</td>") ;
155     w. write("</tr>") ;
156     
157     w. write("<td colspan='2'>");
158     w. write("<label>");
159     w. write(res.getString("UIAccountConfiguration.label.signature"));
160     w. write("</label><br/>") ;
161     w. write("<pre>") ;
162     w. write(ft_.format(account.getSignature()));
163     w. write("</pre>") ;
164     w. write("</td>") ;
165     w. write("</tr>") ;
166     
167     w. write("<tr>") ;
168     w. write("<td colspan='2' align='center'>");
169     linkRenderer_.render(w, uiAccConfig, res.getString("UIAccountConfiguration.button.edit-account"),
170                          UIAccountConfiguration.editAccountParams_);
171     linkRenderer_.render(w, uiAccConfig , res.getString("UIAccountConfiguration.button.delete-account"),
172                          UIAccountConfiguration.deleteAccountParams_);
173     w. write("</td>") ;
174     w. write("</tr>") ;
175     w. write("</tr>") ;
176     w.write("</table>") ;
177   }
178 }
Popular Tags