1 package sessionViewer.presentation; 2 3 import sessionViewer.spec.*; 4 import sessionViewer.SessionViewer; 5 import java.util.Vector ; 7 import java.io.IOException ; 8 9 import com.lutris.appserver.server.httpPresentation.HttpPresentation; 11 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms; 12 import com.lutris.appserver.server.httpPresentation.HttpPresentationException; 13 import org.w3c.dom.html.HTMLAnchorElement; 14 import org.w3c.dom.html.HTMLMetaElement; 15 import org.w3c.dom.Node ; 16 17 public class ListPresentation implements HttpPresentation { 18 19 private static ListHTML list; 20 21 static String refresh = null; 22 23 public void run(HttpPresentationComms comms) throws HttpPresentationException, IOException { 24 25 try{ 26 if (refresh==null){ 27 refresh = SessionViewer.refresh; 28 } 29 OutputList(comms); 30 }catch(Exception e){ 31 } 33 try { 34 } catch (Exception exe){} 35 } 36 37 38 public static void OutputList(HttpPresentationComms comms) throws Exception { 39 40 try { 41 Integer.parseInt(comms.request.getParameter("refresh")); 42 refresh = comms.request.getParameter("refresh"); 43 } catch (Exception e) {} 44 45 ApplicationList applicationList=ApplicationListFactory.getApplicationList("sessionViewer.business.ApplicationListImpl"); 46 Vector [] lists=applicationList.getList(); 47 48 Vector appList = lists[0]; 49 Vector activeSessions = lists[1]; 50 51 52 list = (ListHTML)comms.xmlcFactory.create(ListHTML.class); 53 54 Node applicationElementRow = list.getElementAppliactions_row(); 55 Node no_entries_row = list.getElementNo_entries_row(); 56 Node application_row = list.getElementAppliactions_row(); 57 58 HTMLMetaElement metaRefresh = list.getElementRefresh(); 59 60 if (refresh.equals("0")){ 61 metaRefresh.getParentNode().removeChild(metaRefresh); 62 }else { 63 metaRefresh.setContent(refresh); 64 } 65 66 if (appList.size() == 0) { 67 68 application_row.getParentNode().removeChild(application_row); 69 70 }else if (appList.size()==activeSessions.size()){ 71 no_entries_row.getParentNode().removeChild(no_entries_row); 72 73 for (int i=0; i<appList.size(); i++) { 74 75 String appName = (String ) appList.elementAt(i); 76 77 try { 78 if(appName.length()!=0) 79 list.setTextAppName(appName.substring(1)); 80 else 81 break; 82 } catch (IllegalArgumentException ex){ 83 list.setTextAppName("Couldn't get Application Name!"); 84 } 85 HTMLAnchorElement anchorView = list.getElementView(); 86 anchorView.setHref("ApplicationPresentation.po?id="+ appList.elementAt(i)); 87 88 anchorView.setTitle("Click to view Application sessions in more detail!"); 89 try { 90 list.setTextView(((Integer )activeSessions.elementAt(i)).toString()); 91 } catch (IllegalArgumentException ex){ 92 list.setTextView("Couldn't get active session count!"); 93 } 94 95 HTMLAnchorElement anchorSummary = list.getElementSummary(); 96 anchorSummary.setHref("AppDetailPresentation.po?id="+ appList.elementAt(i)); 97 98 anchorSummary.setTitle("Click to view Application Sessions detail summary page!"); 99 list.setTextSummary("Summary"); 100 101 applicationElementRow.getParentNode().insertBefore(applicationElementRow.cloneNode(true), 102 applicationElementRow); 103 104 } 105 applicationElementRow.getParentNode().removeChild(applicationElementRow); 106 } 107 comms.response.writeDOM(list); 108 109 } 110 } 111 112 | Popular Tags |