process(null,templateFilename, (TemplateModelRoot)null, out, locale);
}
+
+ /**
+ * Mischt die freemarker-Struktur <code>tmr</code> mit
+ * Template <code>templateFilename</code> und gibt das Ergebnis an den PrintWriter
+ * <code>out</code>
+ *
+ * @param templateFilename
+ * @param mergeData
+ * @param out
+ * @exception HTMLParseException
+ */
+ public static void process(HttpServletResponse res,String templateFilename,
+ TemplateModelRoot tmr, PrintWriter out, Locale locale)
+ throws HTMLParseException {
+ process(res,templateFilename,tmr,null,out,locale);
+
+ }
/**
* Mischt die freemarker-Struktur <code>tmr</code> mit
* @param out
* @exception HTMLParseException
*/
- public static void process(HttpServletResponse res,String templateFilename,
- TemplateModelRoot tmr, PrintWriter out, Locale locale)
- throws HTMLParseException {
- if (out==null) throw new HTMLParseException("no outputstream");
- Template tmpl = getTemplateFor(templateFilename);
- if (tmpl == null) throw new HTMLParseException("no template: " + templateFilename);
- if (tmr==null) tmr = new SimpleHash();
-
- /** @todo what is this for? (rk) */
- String session="";
- if (res!=null) {
- session=res.encodeURL("");
- }
-
- /** @todo why do we double those? should be cleaned up and
- * statically initialized, we do not need to assemble a config
- * hash everytime we give out a page, only exception is
- * date "now" // rk */
- // put standard configuration into tempalteRootmodel
- SimpleHash configHash = new SimpleHash();
- configHash.put("producerDocRoot", new SimpleScalar(producerDocRoot));
- configHash.put("storageRoot", new SimpleScalar(producerStorageRoot));
- configHash.put("productionHost", new SimpleScalar(productionHost));
- configHash.put("openAction", new SimpleScalar(openAction));
- configHash.put("actionRootLogin",new SimpleScalar(actionRoot));
- configHash.put("docRoot", new SimpleScalar(docRoot));
- configHash.put("now", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
- configHash.put("actionRoot", new SimpleScalar(actionRoot+session));
- configHash.put("productionHost", new SimpleScalar(productionHost));
- configHash.put("videoHost", new SimpleScalar(videoHost));
- configHash.put("audioHost", new SimpleScalar(audioHost));
- configHash.put("imageHost", new SimpleScalar(imageHost));
- configHash.put("mirVersion", new SimpleScalar(MirConfig.getProp("Mir.Version")));
- // this conform to updated freemarker syntax
- configHash.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
+ public static void process(HttpServletResponse res,String templateFilename,
+ TemplateModelRoot tmr, TemplateModelRoot popups,
+ PrintWriter out, Locale locale)
+ throws HTMLParseException {
+ if (out==null) throw new HTMLParseException("no outputstream");
+ Template tmpl = getTemplateFor(templateFilename);
+ if (tmpl == null) throw new HTMLParseException("no template: " + templateFilename);
+ if (tmr==null) tmr = new SimpleHash();
+
+ /** @todo what is this for? (rk) */
+ String session="";
+ if (res!=null) {
+ session=res.encodeURL("");
+ }
+
+ // put standard configuration into tempalteRootmodel
+ SimpleHash configHash = new SimpleHash();
+ configHash.put("producerDocRoot", new SimpleScalar(producerDocRoot));
+ configHash.put("storageRoot", new SimpleScalar(producerStorageRoot));
+ configHash.put("productionHost", new SimpleScalar(productionHost));
+ configHash.put("openAction", new SimpleScalar(openAction));
+ configHash.put("actionRootLogin",new SimpleScalar(actionRoot));
+ configHash.put("docRoot", new SimpleScalar(docRoot));
+ configHash.put("now", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
+ configHash.put("actionRoot", new SimpleScalar(actionRoot+session));
+ configHash.put("productionHost", new SimpleScalar(productionHost));
+ configHash.put("videoHost", new SimpleScalar(videoHost));
+ configHash.put("audioHost", new SimpleScalar(audioHost));
+ configHash.put("imageHost", new SimpleScalar(imageHost));
+ configHash.put("mirVersion", new SimpleScalar(MirConfig.getProp("Mir.Version")));
+ // this conform to updated freemarker syntax
+ configHash.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
+
+ SimpleHash outPutHash = new SimpleHash();
- SimpleHash outPutHash = new SimpleHash();
- outPutHash.put("data",tmr);
- outPutHash.put("config", configHash);
-
- MessageResources messages = MessageResources.getMessageResources("admin");
- outPutHash.put("lang", new MessageMethodModel(locale, messages) );
-
- tmpl.process(outPutHash,out);
- }
+ if(popups!=null){
+ outPutHash.put("popups",popups);
+ try{
+ while(((SimpleList)popups).hasNext()){
+ theLog.printDebugInfo(((SimpleList)popups).next().toString());
+ }
+ }catch(Exception e){}
+ }
+ outPutHash.put("data",tmr);
+ outPutHash.put("config", configHash);
+
+ MessageResources messages = MessageResources.getMessageResources("admin");
+ outPutHash.put("lang", new MessageMethodModel(locale, messages) );
+
+ tmpl.process(outPutHash,out);
+ }
/**
import freemarker.template.SimpleHash;
import freemarker.template.TemplateModelRoot;
+import freemarker.template.TemplateModel;
+
import mir.entity.EntityList;
import mir.misc.*;
import mir.module.AbstractModule;
}
}
- // 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
* @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
try {
SimpleHash mergeData = new SimpleHash();
mergeData.put("new", "1");
- mergeData.put("mediafolderPopupData",
- DatabaseMediafolder.getInstance().getPopupData());
- deliver(req, res, mergeData, templateObjektString);
+ SimpleHash popups = new SimpleHash();
+ popups.put("mediafolderPopupData",DatabaseMediafolder.getInstance().getPopupData());
+ deliver(req, res, mergeData, popups, templateObjektString);
}
catch (Exception e) { throw new ServletModuleException(e.toString());}
}
throws ServletModuleException {
if (idParam!=null && !idParam.equals("")) {
try {
- EntityImages entity = (EntityImages)mainModule.getById(idParam);
- SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(entity);
- mergeData.put("mediafolderPopupData",
- DatabaseMediafolder.getInstance().getPopupData());
- deliver(req, res, mergeData, templateObjektString);
+ SimpleHash popups = new SimpleHash();
+ popups.put("mediafolderPopupData",DatabaseMediafolder.getInstance().getPopupData());
+ deliver(req, res, mainModule.getById(idParam),popups,
+ templateObjektString);
} catch (ModuleException e) {
throw new ServletModuleException(e.toString());
} catch (StorageObjectException e) {