2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.shale.examples.test.dialog.scxml;
21
22 import javax.faces.context.FacesContext;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.shale.dialog.Constants;
27 import org.apache.shale.dialog.DialogContext;
28 import org.apache.shale.dialog.DialogContextManager;
29 import org.apache.shale.dialog.DialogHelper;
30
31 /***
32 * <p>Utility actions for the wizard dialog series of tests.</p>
33 */
34 public class Wizard {
35
36
37
38
39
40 /***
41 * <p>Log instance for this class.</p>
42 */
43 private Log log = LogFactory.getLog(Wizard.class);
44
45
46
47
48
49 /***
50 * <p>Log the fact that this wizard dialog was cancelled.</p>
51 */
52 public String cancel() {
53
54 if (log.isInfoEnabled()) {
55 log.info("Wizard dialog was cancelled");
56 }
57
58 return "cancelled";
59
60 }
61
62
63 /***
64 * <p>Log the fact that this wizard dialog was finished.</p>
65 */
66 public String finish() {
67
68 if (log.isInfoEnabled()) {
69 log.info("Wizard dialog was finished");
70 }
71
72 return "finished";
73
74 }
75
76
77 /***
78 * <p>Set up the wizard state information with dummy data. This is an action
79 * state that is invoked by the dialog.</p>
80 */
81 public String setup() {
82
83 FacesContext context = FacesContext.getCurrentInstance();
84 DialogContext dcontext = DialogHelper.getDialogContext(context);
85 if (log.isInfoEnabled()) {
86 log.info("Setting up WizardData for a new dialog context id " + dcontext.getId());
87 }
88
89 WizardData data = (WizardData) dcontext.getData();
90 data.setUsername("initUsername");
91 data.setPassword("initPassword");
92 data.setName("initName");
93 data.setAddress1("initAddress1");
94 data.setAddress2("initAddress2");
95 data.setCity("initCity");
96 data.setState("initState");
97 data.setZipCode("initZipCode");
98 data.setAdministrator(false);
99 data.setEnabled(true);
100
101 return "success";
102
103 }
104
105
106 /***
107 * <p>Programmatically start an instance of the wizard dialog.</p>
108 */
109 public String start() {
110
111 if (log.isInfoEnabled()) {
112 log.info("Starting a wizard dialog programmatically");
113 }
114
115 FacesContext context = FacesContext.getCurrentInstance();
116 DialogContextManager manager =
117 DialogHelper.getDialogContextManager(context);
118 DialogContext dcontext = manager.create(context, "wizard");
119 dcontext.start(context);
120 return null;
121
122 }
123
124
125 }