KickJava   Java API By Example, From Geeks To Geeks.

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


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.language.Messages;
12 import com.genimen.djeneric.repository.exceptions.DjenericException;
13 import com.genimen.djeneric.web.renderers.DialogRenderer;
14 import com.genimen.djeneric.web.util.DjenericSessionManager;
15 import com.genimen.djeneric.web.util.DjenericXSLTransform;
16
17 public class DialogCommand
18 {
19   DialogRenderer _renderer = new DialogRenderer();
20
21   public void get(DjenericSessionManager sessionManager, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
22       throws IOException JavaDoc, ServletException JavaDoc, DjenericException
23   {
24     try
25     {
26       response.setContentType("text/html; charset=UTF-8");
27
28       DjenericXSLTransform xsl = sessionManager.getTransformer();
29
30       String JavaDoc title = (String JavaDoc) request.getParameter("title");
31       String JavaDoc titleid = (String JavaDoc) request.getParameter("titleid");
32       
33       String JavaDoc t1 = (String JavaDoc) request.getParameter("t1");
34       String JavaDoc t2 = (String JavaDoc) request.getParameter("t2");
35       String JavaDoc t3 = (String JavaDoc) request.getParameter("t3");
36       String JavaDoc t4 = (String JavaDoc) request.getParameter("t4");
37       String JavaDoc t5 = (String JavaDoc) request.getParameter("t5");
38       
39       if(title == null && titleid != null) title = Messages.getString(titleid, t1, t2, t3, t4, t5);
40       
41       String JavaDoc msg = (String JavaDoc) request.getParameter("msg");
42       String JavaDoc msgid = (String JavaDoc) request.getParameter("msgid");
43
44       String JavaDoc m1 = (String JavaDoc) request.getParameter("m1");
45       String JavaDoc m2 = (String JavaDoc) request.getParameter("m2");
46       String JavaDoc m3 = (String JavaDoc) request.getParameter("m3");
47       String JavaDoc m4 = (String JavaDoc) request.getParameter("m4");
48       String JavaDoc m5 = (String JavaDoc) request.getParameter("m5");
49
50       if(msg == null && msgid != null) msg = Messages.getString(msgid, m1, m2, m3, m4, m5);
51       
52       String JavaDoc buttons = (String JavaDoc) request.getParameter("buttons");
53       
54       boolean escape = "true".equalsIgnoreCase(request.getParameter("escape")) ||"yes".equalsIgnoreCase(request.getParameter("escape"));
55       
56       int width = 0;
57       int height = 0;
58       
59       if(request.getParameter("width") != null) width = Integer.parseInt(request.getParameter("width"));
60       if(request.getParameter("height") != null) height = Integer.parseInt(request.getParameter("height"));
61       
62       Document JavaDoc doc = _renderer.asXml(title, msg, buttons, width, height, escape);
63
64       String JavaDoc page = xsl.transform(doc, "dialogs/dialog.xsl");
65       response.getWriter().print(page);
66     }
67     catch (Exception JavaDoc e)
68     {
69       throw new ServletException JavaDoc(e);
70     }
71   }
72
73   public void post(DjenericSessionManager sessionManager, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
74   {
75
76   }
77 }
78
Popular Tags