01: /*
02: * Copyright (c) Mateusz Prokopowicz. All Rights Reserved.
03: */
04:
05: package com.technoetic.xplanner.actions;
06:
07: import javax.servlet.http.HttpServletRequest;
08: import javax.servlet.http.HttpServletResponse;
09:
10: import org.apache.log4j.Logger;
11: import org.apache.struts.action.Action;
12: import org.apache.struts.action.ActionForm;
13: import org.apache.struts.action.ActionForward;
14: import org.apache.struts.action.ActionMapping;
15: import org.apache.struts.action.DynaActionForm;
16:
17: import com.technoetic.xplanner.util.TimeGenerator;
18:
19: public class PutTheClockForwardAction extends Action {
20: public static final Logger LOG = Logger
21: .getLogger(PutTheClockForwardAction.class);
22: public static final String OFFSET_IN_DAYS_KEY = "dayOffset";
23:
24: private TimeGenerator clock;
25:
26: public void setTimeGenerator(TimeGenerator clock) {
27: this .clock = clock;
28: }
29:
30: public ActionForward execute(ActionMapping mapping,
31: ActionForm actionForm, HttpServletRequest request,
32: HttpServletResponse response) throws Exception {
33:
34: int offsetInDays = 0;
35: try {
36: offsetInDays = Integer.parseInt(request
37: .getParameter(OFFSET_IN_DAYS_KEY));
38:
39: } catch (NumberFormatException e) {
40: }
41: if (offsetInDays > 0) {
42: clock.moveCurrentDay(offsetInDays);
43: } else {
44: clock.reset();
45: }
46: String returnto = request
47: .getParameter(EditObjectAction.RETURNTO_PARAM);
48: if (returnto != null) {
49: return new ActionForward(returnto, true);
50: }
51: return mapping.findForward("view/projects");
52: }
53: }
|