1 7 8 package org.enhydra.snapper.presentation; 9 10 11 import org.w3c.dom.html.*; 12 import org.w3c.dom.*; 13 14 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 { 27 28 PathTypeHTML pathTypeHTML; 29 PathType[] pathList; 30 31 pathTypeHTML = (PathTypeHTML)comms.xmlcFactory.create(PathTypeHTML.class); 32 33 String name = comms.request.getParameter("tName"); 34 String add = comms.request.getParameter("add"); 35 String 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 e) {throw new Exception ("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 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 link; 68 69 for (int num = 0; num < pathList.length; num++) { 70 try{ 71 PathType current = pathList[num]; 72 pathTypeHTML.setTextPathTypeName(current.getName()); 74 link = "PathTypePresentation.po?action=delete&id=" + current.getID(); 75 pathTypeHTML.getElementDeleteLink().setHref(link); 76 79 pathTable.appendChild(templateRow.cloneNode(true)); 81 } 82 83 catch (Exception ex) {ex.printStackTrace();} 84 } 85 templateRow.getParentNode().removeChild(templateRow); 86 return pathTypeHTML; 88 } 89 90 } 91 | Popular Tags |