/*
* 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
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);
}
}
}
- //
- // 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 {