View Javadoc

1   /* ===================================================================
2    * Copyright 2002-05 SRI International.
3    * Released under the MOZILLA PUBLIC LICENSE Version 1.1
4    * which can be obtained at http://www.mozilla.org/MPL/MPL-1.1.html
5    * This software is distributed on an "AS IS"
6    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
7    * See the License for the specific language governing rights and
8    * limitations under the License.
9    * =================================================================== */
10  package com.sri.emo.wizard.creation.management;
11  
12  import com.jcorporate.expresso.core.controller.Controller;
13  import com.jcorporate.expresso.core.controller.ControllerException;
14  import com.jcorporate.expresso.core.controller.ExpressoRequest;
15  import com.jcorporate.expresso.core.controller.ExpressoResponse;
16  import com.jcorporate.expresso.core.controller.Transition;
17  import com.jcorporate.expresso.core.db.DBException;
18  import com.sri.common.controller.StateHandler;
19  
20  /***
21   * @author Michael Rimov
22   */
23  public class PromptChooseCriteria implements StateHandler {
24  
25      /***
26       * The name of this state as referred to by the Expresso Controller
27       */
28      public static final String STATE_NAME = "promptChooseCriteria";
29  
30      /***
31       * The description of this state as referred to by the Expresso Controller.
32       */
33      public static final String STATE_DESCRIPTION = "Choose Parts Criteria";
34  
35  
36      /***
37       * Parent controller backreference.
38       */
39      private final Controller parent;
40  
41  
42      /***
43       * CompletionBean manager.
44       */
45      private final CreationBeanManager beanManager;
46  
47  
48      /***
49       * Constructor that takes the owner controller as a paramter.
50       *
51       * @param owner Controller the owning controller.
52       */
53      public PromptChooseCriteria(Controller owner) {
54          parent = owner;
55          beanManager = new CreationBeanManager();
56      }
57  
58      /***
59       * Special construcor that allows substitution of the bean manager.
60       *
61       * @param owner          Controller
62       * @param specialManager CompletionBeanManager
63       */
64      public PromptChooseCriteria(Controller owner, CreationBeanManager specialManager) {
65          parent = owner;
66          beanManager = specialManager;
67      }
68  
69      /***
70       * Called to handle the request.
71       *
72       * @param request  ControllerRequest The Function's ControllerRequest
73       *                 object.
74       * @param response ControllerResponse The Function's ControllerResponse
75       *                 object.
76       * @throws DBException         upon underlying database exception error.
77       * @throws ControllerException upon underlying ControllerException error.
78       */
79      public void handleRequest(final ExpressoRequest request, final ExpressoResponse response) throws DBException,
80              ControllerException {
81          response.setTitle("Creation Wiz Creator, Part 3");
82  
83  
84          if (beanManager.handleSessionTimeout(request, response)) {
85              return;
86          }
87          //Creates the action form
88          beanManager.getActionForm(request);
89  
90          //Create navigation transitions
91          Transition back = new Transition(PromptChooseParts.STATE_NAME, parent);
92          back.setName("back");
93          back.setLabel("Back");
94          response.add(back);
95  
96          Transition next = new Transition(DoChooseCriteria.STATE_NAME, parent);
97          next.setName("next");
98          next.setLabel("Next");
99          response.add(next);
100     }
101 }