1 package com.sri.emo.wizard.selection.management;
2
3 import com.jcorporate.expresso.core.controller.*;
4 import com.jcorporate.expresso.core.db.DBException;
5 import com.sri.common.controller.StateHandler;
6 import com.sri.emo.dbobj.WizStep;
7
8
9 /***
10 * State that prompts for instructions.
11 *
12 * @author Michael Rimov
13 */
14 public class PromptInstructions extends EditFinalState implements StateHandler {
15
16 /***
17 * Id of the input parameter on the form.
18 */
19 public static final String PARAM_INPUT_ID = "Emo.StepType";
20
21 /***
22 * Constant for access to this state.
23 */
24 public static final String STATE_NAME = "promptInstructions";
25
26 /***
27 * Constant for description of this state.
28 */
29 public static final String STATE_DESCRIPTION = "Enter Instructions For Step";
30
31 /***
32 * Default constructor.
33 *
34 * @param wizId The wizard ID.
35 * @param stepId The step ID which may be null if we are dealing with a new step.
36 * @throws DBException Upon database exception.
37 */
38 public PromptInstructions(final String wizId, final String stepId) throws DBException {
39 super(wizId, stepId);
40 }
41
42 /***
43 * Prompts for any instructions. There are no additional types - per se
44 * <p>{@inheritDoc}</p>
45 *
46 * @param request ExpressoRequest The Function's ExpressoRequest
47 * object.
48 * @param response ExpressoResponse The Function's ExpressoResponse
49 * object.
50 * @throws DBException upon underlying database exception error.
51 * @throws ControllerException upon underlying ControllerException error.
52 */
53 public void handleRequest(final ExpressoRequest request, final ExpressoResponse response)
54 throws DBException, ControllerException {
55 String title = "Enter Instructions for " + getStepTitle();
56 response.setTitle(title);
57 response.add(new Output("pageTitle", title));
58
59
60 ErrorCollection ec = request.getErrorCollection();
61 if (ec == null) {
62 ec = new ErrorCollection();
63 }
64
65 WizStep step = getStepFromParameters(request, ec);
66 if (ec.getErrorCount() > 0) {
67 response.saveErrors(ec);
68 }
69
70
71 Block commonDef = renderCommonControls(step, request, response);
72 response.add(commonDef);
73
74 addStepTypeLabel(response, step);
75 if (isEditing()) {
76 Transition edit = buildEditTypeTransition(step);
77 response.add(edit);
78 }
79
80
81 Transition save = buildSaveAndReturnTransition(step);
82 response.add(save);
83
84
85 response.add(buildCancelTransition());
86 }
87 }