01: /*
02: * Created on 20 Jul 2007
03: */
04: package uk.org.ponder.rsf.swf.support;
05:
06: import uk.org.ponder.rsf.componentprocessor.ComponentProcessor;
07: import uk.org.ponder.rsf.components.UIComponent;
08: import uk.org.ponder.rsf.components.UIForm;
09: import uk.org.ponder.rsf.components.UIInternalLink;
10: import uk.org.ponder.rsf.swf.viewparams.SWFViewParams;
11: import uk.org.ponder.rsf.viewstate.AnyViewParameters;
12: import uk.org.ponder.rsf.viewstate.ViewParameters;
13:
14: /** Traverses the outgoing component tree, looking for any issued SWFViewParams
15: * that should be filled in with the key of any active flow for this view.
16: *
17: * @author Antranig Basman (antranig@caret.cam.ac.uk)
18: */
19:
20: public class SWFFixer implements ComponentProcessor {
21:
22: private SWFExecutor executor;
23:
24: public void setExecutor(SWFExecutor executor) {
25: this .executor = executor;
26: }
27:
28: private void fillInFlowKey(ViewParameters viewparams,
29: SWFViewParams swfparams) {
30: if (viewparams instanceof SWFViewParams) {
31: SWFViewParams linkparams = (SWFViewParams) viewparams;
32: if (linkparams.event != null
33: && linkparams.flowExecutionKey == null) {
34: linkparams.flowExecutionKey = swfparams.flowExecutionKey;
35: }
36: }
37: }
38:
39: public void processComponent(UIComponent toprocesso) {
40: AnyViewParameters incoming = executor.getIncomingParameters();
41: if (incoming instanceof SWFViewParams) {
42: SWFViewParams swfparams = (SWFViewParams) incoming;
43: if (toprocesso instanceof UIInternalLink) {
44: UIInternalLink toprocess = (UIInternalLink) toprocesso;
45: fillInFlowKey(toprocess.viewparams, swfparams);
46: } else if (toprocesso instanceof UIForm) {
47: UIForm toprocess = (UIForm) toprocesso;
48: if (toprocess.viewparams == null) {
49: toprocess.viewparams = (ViewParameters) incoming
50: .copy();
51: } else
52: fillInFlowKey(toprocess.viewparams, swfparams);
53: }
54: }
55: }
56:
57: }
|