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 package org.apache.shale.dialog.scxml.action;
19
20 import java.util.Collection;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.commons.scxml.ErrorReporter;
25 import org.apache.commons.scxml.EventDispatcher;
26 import org.apache.commons.scxml.SCInstance;
27 import org.apache.commons.scxml.SCXMLExpressionException;
28 import org.apache.commons.scxml.model.Action;
29 import org.apache.commons.scxml.model.ModelException;
30 import org.apache.shale.dialog.scxml.DialogProperties;
31 import org.apache.shale.dialog.scxml.Globals;
32
33 /***
34 * <p>Custom Commons SCXML action to set the JSF view identifier of the
35 * next view to be rendered by this dialog.</p>
36 *
37 * @since 1.0.4
38 *
39 * $Id: ViewAction.java 486006 2006-12-12 03:46:29Z rahul $
40 */
41 public class ViewAction extends Action {
42
43 /***
44 * <p>Set nextViewId in dialog properties, which will be the next view
45 * rendered by this dialog.</p>
46 *
47 * @param evtDispatcher The EventDispatcher for this execution instance
48 * @param errRep The ErrorReporter
49 * @param scInstance The state machine execution instance information
50 * @param appLog The application log
51 * @param derivedEvents The collection of internal events
52 * @throws ModelException If execution causes a non-deterministic state
53 * @throws SCXMLExpressionException Bad expression
54 */
55 public void execute(EventDispatcher evtDispatcher, ErrorReporter errRep,
56 SCInstance scInstance, Log appLog, Collection derivedEvents)
57 throws ModelException, SCXMLExpressionException {
58
59 DialogProperties dp = (DialogProperties) scInstance.getRootContext().
60 get(Globals.DIALOG_PROPERTIES);
61 dp.setNextViewId(viewId);
62
63 if (log().isDebugEnabled()) {
64 log().debug("<view>: Setting next view ID to '" + viewId + "'");
65 }
66
67 }
68
69 /***
70 * The JSF view identifier for the next view to be rendered by
71 * this dialog.
72 */
73 private String viewId = null;
74
75 /***
76 * Get the view identifier.
77 *
78 * @return The view identifier
79 */
80 public String getViewId() {
81 return viewId;
82 }
83
84 /***
85 * Set the view identifier.
86 *
87 * @param viewId The view identifier
88 */
89 public void setViewId(String viewId) {
90 this.viewId = viewId;
91 }
92
93
94
95 /***
96 * <p>The <code>Log</code> instance for this class. This value is lazily
97 * instantiated, and is also transient and may need to be regenerated.</p>
98 */
99 private transient Log log = null;
100
101
102 /***
103 * <p>Return the <code>Log</code> instance for this instance.</p>
104 *
105 * @return The {@link Log} instance used by this manager
106 */
107 private Log log() {
108 if (this.log == null) {
109 this.log = LogFactory.getLog(ViewAction.class);
110 }
111 return this.log;
112 }
113
114 }