KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > presentation > SiteListPresentation


1 /*
2  * snapper
3  *
4  * Enhydra super-servlet presentation object
5  *
6  */

7
8 package org.enhydra.snapper.presentation;
9
10
11
12 import org.w3c.dom.html.*;
13 import org.w3c.dom.*;
14
15 // Enhydra SuperServlet specification imports
16
import org.enhydra.snapper.spec.*;
17
18 import org.enhydra.snapper.presentation.html.*;
19 import org.enhydra.xml.xmlc.XMLObject;
20
21
22 public class SiteListPresentation extends BasePO {
23
24
25     protected XMLObject getDOM() throws Exception JavaDoc {
26
27         SiteListHTML siteList;
28         Site[] list;
29         String JavaDoc id;
30
31         siteList = (SiteListHTML)comms.xmlcFactory.create(SiteListHTML.class);
32         id = comms.request.getParameter("id");
33         
34         if (comms.request.getParameter("i") != null) {
35             //siteList.setTextIndexedSiteName("Finished indexing site: " + comms.request.getParameter("i"));
36
siteList.getElementInfo2().setValue("Indexing site: " + comms.request.getParameter("i"));
37         }
38         
39         if (comms.request.getParameter("u") != null) {
40             //iteList.setTextIndexedSiteName("Finished updating site: " + comms.request.getParameter("u"));
41
siteList.getElementInfo2().setValue("Updating site: " + comms.request.getParameter("u"));
42         }
43         
44         if (comms.request.getParameter("l") != null) {
45             //siteList.setTextIndexedSiteName("SITE LOCKED! Site is already being indexed/updated: " + comms.request.getParameter("l"));
46
siteList.getElementInfo2().setValue("SITE LOCKED! Site is already being indexed/updated: " + comms.request.getParameter("l"));
47         }
48                     
49         
50         
51         try {
52             SiteList sl = SiteListFactory.getSiteList("org.enhydra.snapper.business.SiteListImpl");
53             
54             list = sl.getList(dbTransaction);
55             
56         }catch (Exception JavaDoc ex){
57             System.out.println("Exception: "+ex);
58             list = null;
59         }
60         
61         HTMLTableRowElement templateRow = siteList.getElementTemplateRow();
62         
63         HTMLElement nameCellTemplate = siteList.getElementName();
64         HTMLElement documentsCellTemplate = siteList.getElementDocuments();
65         HTMLElement queriesCellTemplate = siteList.getElementQueries();
66         HTMLElement updatedCellTemplate = siteList.getElementUpdated();
67
68         templateRow.removeAttribute("id");
69         nameCellTemplate.removeAttribute("id");
70         documentsCellTemplate.removeAttribute("id");
71         queriesCellTemplate.removeAttribute("id");
72         updatedCellTemplate.removeAttribute("id");
73         
74         Node sitesTable = templateRow.getParentNode();
75         String JavaDoc link;
76         
77         for (int numSites = 0; numSites < list.length; numSites++) {
78             try{
79             Site currentSite = list[numSites];
80             // set text of new cells to values from string array
81
siteList.setTextName(currentSite.getName());
82             siteList.setTextDocuments(String.valueOf(currentSite.getFILENR()));
83             siteList.setTextQueries(String.valueOf(currentSite.getQUERYNR()));
84             if (currentSite.getLASTUPDATE() == null) {
85                 siteList.setTextUpdated("never");
86             }
87             else
88                 siteList.setTextUpdated(currentSite.getLASTUPDATE().toLocaleString());
89                         
90             link = "javascript:indexLock('" + currentSite.getID() + "');"; //+ currentSite.getID();
91
siteList.getElementIndexLink().setHref(link);
92             
93             link = "javascript:checkLock('DeleteSite.po?id=" + currentSite.getID() + "');";
94             siteList.getElementDeleteLink().setHref(link);
95             
96             link = "javascript:updateLock('" + currentSite.getID() + "');";
97             siteList.getElementUpdateLink().setHref(link);
98             
99             link = "UpdateSitePresentation.po?id=" + currentSite.getID();
100             siteList.getElementUpdateSiteLink().setHref(link);
101
102             //siteList.setTextLikeThisDisc();
103
sitesTable.appendChild(templateRow.cloneNode(true));
104             }
105    
106         catch (Exception JavaDoc ex) {ex.printStackTrace();}
107         }
108         templateRow.getParentNode().removeChild(templateRow);
109         //siteList.setTextTime(now);
110
return siteList;
111     }
112
113 }
114
Popular Tags