KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > web > controller > FilterCommand


1 package com.genimen.djeneric.web.controller;
2
3 import java.io.IOException JavaDoc;
4
5 import javax.servlet.ServletException JavaDoc;
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7 import javax.servlet.http.HttpServletResponse JavaDoc;
8
9 import org.w3c.dom.Document JavaDoc;
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 JavaDoc request, HttpServletResponse JavaDoc response)
25       throws IOException JavaDoc, ServletException JavaDoc, DjenericException
26   {
27     try
28     {
29       WebTree tree = sessionManager.getTree();
30
31       response.setContentType("text/html; charset=UTF-8");
32
33       String JavaDoc 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 JavaDoc excludeName = null;
43         ExtentUsage usage = folder.getExtentUsage();
44         if (folder.isContentsLoadedViaRelation()) excludeName = usage.getVia().getDetailPropertyName();
45
46         Document JavaDoc doc = _renderer.asXml(usage.getExtent(), sessionManager.getPrimarySession(), excludeName);
47
48         String JavaDoc 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 JavaDoc e)
54     {
55       throw new ServletException JavaDoc(e);
56     }
57   }
58
59   public void post(DjenericSessionManager sessionManager, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
60   {
61
62   }
63 }
64
Popular Tags