1 package com.genimen.djeneric.web.controller; 2 3 import java.io.IOException ; 4 5 import javax.servlet.ServletException ; 6 import javax.servlet.http.HttpServletRequest ; 7 import javax.servlet.http.HttpServletResponse ; 8 9 import org.w3c.dom.Document ; 10 11 import com.genimen.djeneric.repository.exceptions.DjenericException; 12 import com.genimen.djeneric.structure.ExtentUsage; 13 import com.genimen.djeneric.web.renderers.FilterRenderer; 14 import com.genimen.djeneric.web.renderers.tree.AbstractWebNode; 15 import com.genimen.djeneric.web.renderers.tree.WebFolder; 16 import com.genimen.djeneric.web.renderers.tree.WebTree; 17 import com.genimen.djeneric.web.util.DjenericSessionManager; 18 import com.genimen.djeneric.web.util.DjenericXSLTransform; 19 20 public class FilterCommand 21 { 22 FilterRenderer _renderer = new FilterRenderer(); 23 24 public void get(DjenericSessionManager sessionManager, HttpServletRequest request, HttpServletResponse response) 25 throws IOException , ServletException , DjenericException 26 { 27 try 28 { 29 WebTree tree = sessionManager.getTree(); 30 31 response.setContentType("text/html; charset=UTF-8"); 32 33 String nodeId = request.getParameter("nodeid"); 34 if (nodeId != null) 35 { 36 AbstractWebNode node = tree.getNode(nodeId); 37 if (!(node instanceof WebFolder)) throw new DjenericException("Node with id " + nodeId + " is not a folder"); 38 WebFolder folder = (WebFolder) node; 39 40 DjenericXSLTransform xsl = sessionManager.getTransformer(); 41 42 String excludeName = null; 43 ExtentUsage usage = folder.getExtentUsage(); 44 if (folder.isContentsLoadedViaRelation()) excludeName = usage.getVia().getDetailPropertyName(); 45 46 Document doc = _renderer.asXml(usage.getExtent(), sessionManager.getPrimarySession(), excludeName); 47 48 String page = xsl.transform(doc, "dialogs/filter.xsl"); 49 response.getWriter().print(page); 50 } 51 else throw new DjenericException("No nodeid parameter specified"); 52 } 53 catch (Exception e) 54 { 55 throw new ServletException (e); 56 } 57 } 58 59 public void post(DjenericSessionManager sessionManager, HttpServletRequest request, HttpServletResponse response) 60 { 61 62 } 63 } 64 | Popular Tags |