1 package mircoders.servlet;
5 import javax.servlet.http.*;
6 import javax.servlet.*;
7 import freemarker.template.*;
13 import mircoders.module.*;
14 import mircoders.storage.*;
17 * ServletModuleBreaking -
18 * Authentified Navigation for Breaking News
23 public class ServletModuleBreaking extends ServletModule
26 // Singelton / Kontruktor
28 private static ServletModuleBreaking instance = new ServletModuleBreaking();
29 public static ServletModule getInstance() { return instance; }
31 private ServletModuleBreaking() {
33 theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Breaking.Logfile"));
34 templateListString = Configuration.getProperty("ServletModule.Breaking.ListTemplate");
35 templateObjektString = Configuration.getProperty("ServletModule.Breaking.ObjektTemplate");
36 templateConfirmString = Configuration.getProperty("ServletModule.Breaking.ConfirmTemplate");
38 mainModule = new ModuleBreaking(DatabaseBreaking.getInstance());
40 catch (StorageObjectException e) {
41 theLog.printDebugInfo("ServletModuleBreaking konnte nicht initialisiert werden");
45 public void list(HttpServletRequest req, HttpServletResponse res)
46 throws ServletModuleException
48 theLog.printDebugInfo("-- breaking: list");
51 SimpleHash mergeData = new SimpleHash();
52 String offset = req.getParameter("offset");
53 if (offset==null || offset.equals("")) offset="0";
54 mergeData.put("offset",offset);
55 EntityList theList = mainModule.getByWhereClause(null, "webdb_create desc", (new Integer(offset)).intValue());
56 mergeData.put("contentlist",HTMLTemplateProcessor.makeSimpleList(theList));
57 if(theList.getOrder()!=null) {
58 mergeData.put("order", theList.getOrder());
59 mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder()));
61 mergeData.put("count", (new Integer(theList.getCount())).toString());
62 mergeData.put("from", (new Integer(theList.getFrom())).toString());
63 mergeData.put("to", (new Integer(theList.getTo())).toString());
64 if (theList.hasNextBatch())
65 mergeData.put("next", (new Integer(theList.getNextBatch())).toString());
66 if (theList.hasPrevBatch())
67 mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
70 HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
72 catch (ModuleException e) {throw new ServletModuleException(e.toString());}
73 catch (IOException e) {throw new ServletModuleException(e.toString());}
74 catch (Exception e) {throw new ServletModuleException(e.toString());}