1 package mircoders.servlet;
6 import javax.servlet.*;
7 import javax.servlet.http.*;
9 import freemarker.template.*;
17 import mircoders.entity.*;
18 import mircoders.storage.*;
19 import mircoders.module.*;
22 * ServletModuleUsers -
23 * liefert HTML fuer Users
29 public class ServletModuleUsers extends mir.servlet.ServletModule
31 // Singelton / Kontruktor
32 private static ServletModuleUsers instance = new ServletModuleUsers();
33 public static ServletModule getInstance() { return instance; }
35 private ServletModuleUsers() {
36 theLog = Logfile.getInstance(this.getClass().getName());
37 templateListString = MirConfig.getProp("ServletModule.Users.ListTemplate");
38 templateObjektString = MirConfig.getProp("ServletModule.Users.ObjektTemplate");
39 templateConfirmString = MirConfig.getProp("ServletModule.Users.ConfirmTemplate");
41 mainModule = new ModuleUsers(DatabaseUsers.getInstance());
43 catch (StorageObjectException e) {
44 theLog.printDebugInfo("servletmoduleusers konnte nicht initialisiert werden");
48 public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
50 String idParam = req.getParameter("id");
51 if (idParam == null) throw new ServletModuleException("Falscher Aufruf: (id) nicht angegeben");
53 deliver(req, res, mainModule.getById(idParam), templateObjektString);
55 catch (ModuleException e) { throw new ServletModuleException(e.toString());}
58 public void add(HttpServletRequest req, HttpServletResponse res)
59 throws ServletModuleException
62 SimpleHash mergeData = new SimpleHash();
63 mergeData.put("new", "1");
64 deliver(req, res, mergeData, templateObjektString);
66 catch (Exception e) { throw new ServletModuleException(e.toString());}
69 public void insert(HttpServletRequest req, HttpServletResponse res)
70 throws ServletModuleException
73 HashMap withValues = getIntersectingValues(req, mainModule.getStorageObject());
74 String id = mainModule.add(withValues);
75 deliver(req, res, mainModule.getById(id), templateObjektString);
77 catch (Exception e) { throw new ServletModuleException(e.toString());}