KickJava   Java API By Example, From Geeks To Geeks.

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


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

7
8 package org.enhydra.snapper.presentation;
9
10
11 import org.w3c.dom.html.*;
12 import org.w3c.dom.*;
13
14 // Enhydra SuperServlet specification imports
15
import org.enhydra.snapper.spec.*;
16
17 import org.enhydra.snapper.presentation.html.*;
18 import org.enhydra.xml.xmlc.XMLObject;
19
20 import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
21
22
23 public class PathTypePresentation extends BasePO {
24
25
26     protected XMLObject getDOM() throws Exception JavaDoc {
27
28         PathTypeHTML pathTypeHTML;
29         PathType[] pathList;
30
31         pathTypeHTML = (PathTypeHTML)comms.xmlcFactory.create(PathTypeHTML.class);
32
33         String JavaDoc name = comms.request.getParameter("tName");
34         String JavaDoc add = comms.request.getParameter("add");
35         String JavaDoc delete = comms.request.getParameter("delete");
36         if (name != null && add!=null)
37         {
38             PathType pathType = null;
39             try{
40                 pathType = PathTypeFactory.getPathType("org.enhydra.snapper.business.PathTypeImpl");
41                 pathType.createNew(dbTransaction);
42                 pathType.setName(name);
43                 pathType.save();
44                 throw new ClientPageRedirectException(comms.request.getAppFileURIPath("PathTypePresentation.po"));
45                 
46             }
47             catch (Exception JavaDoc e) {throw new Exception JavaDoc ("Could not create new PathTye", e);}
48         }
49         
50         try {
51             PathType pt = PathTypeFactory.getPathType("org.enhydra.snapper.business.PathTypeImpl");
52             
53             pathList = pt.getList(dbTransaction);
54             
55         }catch (Exception JavaDoc ex){
56             System.out.println("Exception: "+ex);
57             pathList = null;
58         }
59         
60         HTMLTableRowElement templateRow = pathTypeHTML.getElementTemplateRow();
61         HTMLElement nameCellTemplate = pathTypeHTML.getElementPathTypeName();
62
63         templateRow.removeAttribute("id");
64         nameCellTemplate.removeAttribute("id");
65         
66         Node pathTable = templateRow.getParentNode();
67         String JavaDoc link;
68         
69         for (int num = 0; num < pathList.length; num++) {
70             try{
71             PathType current = pathList[num];
72             // set text of new cells to values from string array
73
pathTypeHTML.setTextPathTypeName(current.getName());
74             link = "PathTypePresentation.po?action=delete&id=" + current.getID();
75             pathTypeHTML.getElementDeleteLink().setHref(link);
76             //HTMLImageElement img = pathTypeHTML.getElementDeleteImage();
77
//img.setSrc("delete16");
78

79             //siteList.setTextLikeThisDisc();
80
pathTable.appendChild(templateRow.cloneNode(true));
81             }
82    
83         catch (Exception JavaDoc ex) {ex.printStackTrace();}
84         }
85         templateRow.getParentNode().removeChild(templateRow);
86         //siteList.setTextTime(now);
87
return pathTypeHTML;
88     }
89
90 }
91
Popular Tags