1 5 package org.exoplatform.portlets.communication.message.renderer.html; 6 7 import java.io.IOException ; 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 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 { 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 { 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 |