1 package sessionViewer.presentation; 2 3 4 import sessionViewer.spec.*; 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.Node ; 15 16 public class ApplicationPresentation implements HttpPresentation { 17 18 private static ApplicationHTML application; 19 20 public void run(HttpPresentationComms comms) throws HttpPresentationException, IOException { 21 22 try{ 23 OutputList(comms); 24 }catch(Exception e){ 25 e.printStackTrace(); 26 } 27 } 28 29 30 public static void OutputList(HttpPresentationComms comms) throws Exception { 31 32 String id = null; 33 try { 34 id = comms.request.getParameter("id"); 35 } catch (Exception e) {} 36 37 38 ApplicationSessionList applicationSessionList=ApplicationSessionListFactory.getApplicationSessionList("sessionViewer.business.ApplicationSessionListImpl"); 39 Vector sessionList=applicationSessionList.getList(id); 40 41 42 43 String sessionID= null; 44 45 application = (ApplicationHTML)comms.xmlcFactory.create(ApplicationHTML.class); 46 47 Node sessionElementRow = application.getElementSessions_row(); 48 Node no_entries_row = application.getElementNo_entries_row(); 49 Node sessions_row = application.getElementSessions_row(); 50 51 application.setTextAppName(id.substring(1) + " Session List"); 52 53 if (sessionList.size() == 0) { 54 55 sessions_row.getParentNode().removeChild(sessions_row); 56 57 }else { 58 no_entries_row.getParentNode().removeChild(no_entries_row); 59 for (int i=0; i<sessionList.size(); i++) { 60 61 sessionID = (String ) sessionList.elementAt(i); 62 63 HTMLAnchorElement anchorView = application.getElementView(); 64 anchorView.setHref("DetailPresentation.po?appid="+id+"&sesid="+ sessionID); 65 anchorView.setTitle("Click to view Application session in more detail!"); 66 try { 67 application.setTextView(sessionID); 68 } catch (IllegalArgumentException ex){ 69 application.setTextView("Couldn't get SessionID!"); 70 } 71 sessionElementRow.getParentNode().insertBefore(sessionElementRow.cloneNode(true), 72 sessionElementRow); 73 74 } 75 sessionElementRow.getParentNode().removeChild(sessionElementRow); 76 } 77 comms.response.writeDOM(application); 78 } 79 } 80 81 | Popular Tags |