made the add() method use _showObject. Fixes a bug that cause the popUps not to show...
authormh <mh>
Sat, 20 Jul 2002 22:24:25 +0000 (22:24 +0000)
committermh <mh>
Sat, 20 Jul 2002 22:24:25 +0000 (22:24 +0000)
source/mircoders/servlet/ServletModuleContent.java

index ddc4d7e..9871d94 100755 (executable)
@@ -24,10 +24,16 @@ import mircoders.entity.*;
 
 /*
  *  ServletModuleContent -
- *  liefert HTML fuer Content
+ *  deliver html for the article admin form.
+ *
+ * @version $Revision: 1.19 $
+ * @author $Author: mh $
+ *
+ * $Log: ServletModuleContent.java,v $
+ * Revision 1.19  2002/07/20 22:24:25  mh
+ * made the add() method use _showObject. Fixes a bug that cause the popUps not to show up when adding an article in the admin
  *
  *
- * @author RK
  */
 
 public class ServletModuleContent extends ServletModule
@@ -140,35 +146,7 @@ public class ServletModuleContent extends ServletModule
 
   public void add(HttpServletRequest req, HttpServletResponse res)
     throws ServletModuleException {
-
-    EntityUsers   user = _getUser(req);
-    SimpleHash mergeData = new SimpleHash();
-    mergeData.put("new", "1");
-    mergeData.put("is_published", "1");
-    String now = StringUtil.date2webdbDate(new GregorianCalendar());
-    mergeData.put("date", new SimpleScalar(now));
-    try {
-    mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList());
-    } catch (ModuleException e) {
-      theLog.printError("themenPopupData could not be fetched.");
-    }
-    try {
-      mergeData.put("articletypePopupData", DatabaseArticleType.getInstance().getPopupData());
-    } catch (Exception e) {
-      theLog.printError("articletype could not be fetched.");
-    }
-    try {
-      mergeData.put("languagePopupData", DatabaseLanguage.getInstance().getPopupData());
-    } catch (Exception e) {
-      theLog.printError("language-popup could not be fetched.");
-    }
-    try {
-    mergeData.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList());
-    } catch (ModuleException e) {
-      theLog.printError("schwerpunktPopupData could not be fetched.");
-    }
-    mergeData.put("login_user", user);
-    deliver(req, res, mergeData, templateObjektString);
+    _showObject(null, req, res);
   }
 
 
@@ -362,15 +340,31 @@ public class ServletModuleContent extends ServletModule
     }
   }
 
-  //
-  // Hilfsmethoden
-
+  /* 
+   * HelperMethod shows the basic article editing form.
+   *
+   * if the "id" parameter is null, it means show an empty form to add a new
+   * article.
+   */ 
   private void _showObject(String id, HttpServletRequest req, HttpServletResponse res)
     throws ServletModuleException {
 
     SimpleHash extraInfo = new SimpleHash();
     try {
-      EntityContent entContent=(EntityContent)mainModule.getById(id);
+      TemplateModelRoot entContent;
+      if (id != null) {
+        entContent = (TemplateModelRoot)mainModule.getById(id);
+      } else {
+        SimpleHash withValues = new SimpleHash();
+        withValues.put("new", "1");
+        withValues.put("is_published", "0");
+        String now = StringUtil.date2webdbDate(new GregorianCalendar());
+        withValues.put("date", new SimpleScalar(now));
+        EntityUsers   user = _getUser(req);
+        withValues.put("login_user", user);
+        entContent = withValues;
+      }
+        
 
       extraInfo.put("themenPopupData", themenModule.getTopicsAsSimpleList());
       try {