View Javadoc

1   /*
2    *  DISCLAIMER
3    */
4   package org.flowfuse.holiday.frontend;
5   
6   import org.apache.commons.logging.Log;
7   import org.apache.commons.logging.LogFactory;
8   import org.flowfuse.base.frontend.BaseFormController;
9   import org.flowfuse.base.model.WorkItem;
10  import org.flowfuse.base.model.WorkflowAction;
11  import org.springframework.web.servlet.ModelAndView;
12  import org.springframework.web.servlet.view.RedirectView;
13  
14  import javax.servlet.http.HttpServletRequest;
15  
16  /***
17   * @author <a href="stefan@flowfuse.org">Stefan Kleineikenscheidt</a>,
18   *         Flowfuse.org
19   * @version $Id: CreateApplicationForm.java,v 1.1 2005/11/20 15:02:28 skleinei Exp $
20   */
21  public class CreateApplicationForm extends BaseFormController {
22  
23    /***
24     * RCS ID
25     */
26    public final static String rcsid = "$Id: CreateApplicationForm.java,v 1.1 2005/11/20 15:02:28 skleinei Exp $";
27  
28    /***
29     * Logger
30     */
31    protected final Log logger = LogFactory.getLog(this.getClass());
32  
33    public CreateApplicationForm() {
34      setFormView("executeAction");
35      setCommandClass(WorkflowAction.class);
36    }
37  
38    protected Object formBackingObject(HttpServletRequest request) throws Exception {
39      WorkItem workItem = new WorkItem();
40      return workItem;
41    }
42  
43    protected ModelAndView onSubmit(Object command) throws Exception {
44  
45      WorkItem workItem = (WorkItem) command;
46  
47      // do workflowInstance action
48      workItem.initializeWorkflow();
49  
50      // TODO check whether user has right to view workflowInstance ...
51      if (true) {
52        // ... if so direct to item list ...
53        return new ModelAndView(new RedirectView("workitem"));
54      } else {
55        // ... otherwise return to work list
56        return new ModelAndView(new RedirectView("worklist"));
57      }
58    }
59  
60    // -- Dependency injection setter --------------------------------------
61  
62  }
63  
64  /* EOF */