KickJava   Java API By Example, From Geeks To Geeks.

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


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.* ;
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.faces.core.renderer.html.ThreeImagePatternButton;
15 import org.exoplatform.portlets.communication.message.component.*;
16 import org.exoplatform.services.communication.message.*;
17
18 /**
19  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
20  * @since Aug 27, 2004
21  * @version $Id: AccountRenderer.java,v 1.6 2004/11/01 15:06:42 tuan08 Exp $
22  */

23 public class AccountRenderer extends HtmlBasicRenderer {
24   public AccountRenderer() {
25     buttonRenderer_ = new ThreeImagePatternButton("ic3-button", "ic3-select-button") ;
26   }
27   
28   public void encodeChildren(FacesContext context, UIComponent component ) throws IOException JavaDoc {
29     UIAccount uiAccount = (UIAccount) component ;
30     ResponseWriter w = context.getResponseWriter() ;
31     ResourceBundle res = getApplicationResourceBundle(context.getExternalContext());
32     Account account = uiAccount.getAccount() ;
33     if(account == null) {
34       renderNoAccountInfo(w, res) ;
35       return ;
36     }
37     w.write("<div class='UIAccount'>") ;
38     buttonRenderer_.render(w, uiAccount, res.getString("UIAccount.button.check-new-message"),
39                            UIAccount.synchronizeParams_);
40     buttonRenderer_.render(w, uiAccount, res.getString("UIAccount.button.compose"),
41                          UIAccount.composeParams_);
42     List folders = uiAccount.getFolders() ;
43     Parameter folderNameParam = new Parameter(UIAccount.FOLDER_NAME, "") ;
44     Parameter[] changeFolderParams = {UIAccount.changeFolderParam_, folderNameParam } ;
45     for(int i = 0; i < folders.size(); i++) {
46       Folder folder = (Folder) folders.get(i);
47       folderNameParam.setValue(folder.getName()) ;
48       buttonRenderer_.render(w, uiAccount, folder.getName(), changeFolderParams);
49     }
50     w.write("</div>") ;
51     renderChildren(context, uiAccount) ;
52   }
53   
54   private void renderNoAccountInfo(ResponseWriter w , ResourceBundle res) throws IOException JavaDoc {
55     w.write("<div class='no-account'>") ;
56     w.write(res.getString("UIAccount.info.need-one-account")) ;
57     w.write("</div>") ;
58   }
59 }
Popular Tags