1 5 package org.exoplatform.portlets.monitor.session.renderer.html; 6 7 import java.util.*; 8 import java.io.IOException ; 9 import java.util.ResourceBundle ; 10 import javax.faces.component.UIComponent; 11 import javax.faces.context.FacesContext; 12 import javax.faces.context.ResponseWriter; 13 import org.exoplatform.container.monitor.SessionMonitor; 14 import org.exoplatform.container.monitor.ActionData; 15 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer; 16 import org.exoplatform.portlets.monitor.session.component.UIActionHistory; 17 23 public class ActionHistoryRenderer extends HtmlBasicRenderer { 24 static private String [] HEADER = { 25 "UISessionMontitor.header.portal", "UISessionMontitor.header.page", 26 "UISessionMontitor.header.request-type", "UISessionMontitor.header.handle-time", 27 "UISessionMontitor.header.parameters", "UISessionMontitor.header.error" 28 } ; 29 30 public void encodeChildren( FacesContext context, UIComponent component ) throws IOException { 31 UIActionHistory uiMonitor = (UIActionHistory) component ; 32 ResponseWriter w = context.getResponseWriter() ; 33 ResourceBundle res = getApplicationResourceBundle(context.getExternalContext()) ; 34 w.write("<table class='UISessionMonitor'>") ; 35 w. write("<tr>") ; 36 for(int i =0 ; i < HEADER.length; i++ ) { 37 w. write("<th>") ; w.write(res.getString(HEADER[i])); w.write("</th>") ; 38 } 39 w. write("</tr>") ; 40 Iterator itr = uiMonitor.getActionHistory().iterator() ; 41 while(itr.hasNext()) { 42 ActionData data = (ActionData) itr.next() ; 43 String page = data.getPage() ; 44 if(page == null || page.length() == 0) page = "N/A" ; 45 w.write("<tr>") ; 46 w. write("<td>") ; w.write(data.getPortal()); w.write("</td>") ; 47 w. write("<td>") ; w.write(page); w.write("</td>") ; 48 w. write("<td>") ; w.write(data.getRequestType()); w.write("</td>") ; 49 w. write("<td>") ; w.write(Long.toString(data.getHandleTime())); w.write("</td>") ; 50 w. write("<td width='400'>") ; w.write(data.getParameters()); w.write("</td>") ; 51 if(data.getError() == null) { 52 w. write("<td>") ; w.write("-"); w.write("</td>") ; 53 } else { 54 w. write("<td align='center'>") ; w.write("view"); w.write("</td>") ; 55 } 56 w.write("</tr>") ; 57 if(data.getError() != null) { 58 w.write("<tr>") ; 59 w. write("<td colspan='5'>") ; w.write(data.getError()); w.write("</td>") ; 60 w.write("</tr>") ; 61 } 62 } 63 w. write("<tr>") ; 64 w. write("<td colspan='5'>") ; 65 linkRenderer_.render(w, uiMonitor , res.getString("UISessionMontitor.button.back"), 66 UIActionHistory.BACK_PARAMS) ; 67 w. write("</td>") ; 68 w. write("</tr>") ; 69 w.write("</table>") ; 70 } 71 } | Popular Tags |