Mir goes GPL
[mir.git] / source / mir / servlet / ServletModule.java
index 84e87bc..2f91ce8 100755 (executable)
@@ -1,7 +1,40 @@
+/*
+ * Copyright (C) 2001, 2002  The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with the com.oreilly.servlet library, any library
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of
+ * the above that use the same license as the above), and distribute linked
+ * combinations including the two.  You must obey the GNU General Public
+ * License in all respects for all of the code used other than the above
+ * mentioned libraries.  If you modify this file, you may extend this exception
+ * to your version of the file, but you are not obligated to do so.  If you do
+ * not wish to do so, delete this exception statement from your version.
+ */
+
 package mir.servlet;
 
 import freemarker.template.SimpleHash;
 import freemarker.template.TemplateModelRoot;
+import freemarker.template.TemplateModel;
+
 import mir.entity.EntityList;
 import mir.misc.*;
 import mir.module.AbstractModule;
@@ -271,22 +304,6 @@ public abstract class ServletModule {
         }
     }
 
-    // Hilfsprozeduren
-    /**
-     public void predeliver(HttpServletResponse res, TemplateModelRoot rtm, String tmpl)
-     throws ServletModuleException {
-     try {
-     PrintWriter out = new LineFilterWriter(res.getWriter());
-     StringWriter a = new StringWriter();
-     deliver(new PrintWriter(a),rtm,tmpl);
-     out.write(a.toString());
-     out.flush();
-     } catch (Exception e) {
-     e.printStackTrace();System.err.println(e.toString());
-     }
-     }
-     */
-
     /**
      * deliver liefert das Template mit dem Filenamen templateFilename
      * an den HttpServletResponse res aus, nachdem es mit den Daten aus
@@ -298,23 +315,41 @@ public abstract class ServletModule {
      * @param tmpl Name des Templates
      * @exception ServletModuleException
      */
-    public void deliver(HttpServletRequest req, HttpServletResponse res, TemplateModelRoot rtm, String templateFilename)
-            throws ServletModuleException {
-        if (rtm == null) rtm = new SimpleHash();
-        try {
-            //PrintWriter out =  new LineFilterWriter(res.getWriter());
-            PrintWriter out = res.getWriter();
-            HTMLTemplateProcessor.process(res, templateFilename, rtm, out, getLocale(req));
-            out.close();
-        }
-        catch (HTMLParseException e) {
-            throw new ServletModuleException(e.toString());
-        }
-        catch (IOException e) {
-            throw new ServletModuleException(e.toString());
-        }
-    }
+       public void deliver(HttpServletRequest req, HttpServletResponse res,
+                                                                                       TemplateModelRoot rtm, TemplateModelRoot popups,
+                                                                                       String templateFilename)
+       throws ServletModuleException {
+               if (rtm == null) rtm = new SimpleHash();
+               try {
+                       PrintWriter out = res.getWriter();
+                       HTMLTemplateProcessor.process(res, templateFilename, rtm, popups, out,
+                                                                                                                                               getLocale(req));
+                       out.close();
+               }       catch (HTMLParseException e) {
+                       throw new ServletModuleException(e.toString());
+               } catch (IOException e) {
+                       throw new ServletModuleException(e.toString());
+               }
+       }
 
+       
+       /**
+        * deliver liefert das Template mit dem Filenamen templateFilename
+        * an den HttpServletResponse res aus, nachdem es mit den Daten aus
+        * TemplateModelRoot rtm gemischt wurde
+        *
+        * @param res Http-Response, die vom Dispatcher durchgereicht wird
+        * @param rtm beinahalten das freemarker.template.TempalteModelRoot mit den
+        *   Daten, die ins Template gemerged werden sollen.
+        * @param tmpl Name des Templates
+        * @exception ServletModuleException
+        */
+       public void deliver(HttpServletRequest req, HttpServletResponse res,
+                                                                                       TemplateModelRoot rtm, String templateFilename)
+       throws ServletModuleException {
+               deliver(req, res, rtm, null, templateFilename);
+       }
+       
     /**
      * deliver liefert das Template mit dem Filenamen templateFilename
      * an den HttpServletResponse res aus, nachdem es mit den Daten aus