1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.flow.builder;
20
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25 import javax.el.ValueExpression;
26 import javax.faces.flow.builder.NavigationCaseBuilder;
27 import org.apache.myfaces.flow.FlowImpl;
28 import org.apache.myfaces.flow.NavigationCaseImpl;
29
30
31
32
33
34 public class NavigationCaseBuilderImpl extends NavigationCaseBuilder
35 {
36 private FlowImpl _facesFlow;
37 private FlowBuilderImpl _flowBuilder;
38 private NavigationCaseImpl _navigationCaseImpl;
39
40 public NavigationCaseBuilderImpl(FlowBuilderImpl flowBuilder, FlowImpl facesFlow)
41 {
42 this._flowBuilder = flowBuilder;
43 this._facesFlow = facesFlow;
44 this._navigationCaseImpl = new NavigationCaseImpl();
45 }
46
47 @Override
48 public NavigationCaseBuilder fromViewId(String fromViewId)
49 {
50
51
52 if (this._navigationCaseImpl.getFromViewId() != null)
53 {
54 this._facesFlow.removeNavigationCase(_navigationCaseImpl);
55 }
56 if (fromViewId != null)
57 {
58 this._navigationCaseImpl.setFromViewId(fromViewId);
59 this._facesFlow.addNavigationCase(_navigationCaseImpl);
60 }
61 return this;
62 }
63
64 @Override
65 public NavigationCaseBuilder fromAction(String fromAction)
66 {
67 this._navigationCaseImpl.setFromAction(fromAction);
68 return this;
69 }
70
71 @Override
72 public NavigationCaseBuilder fromOutcome(String fromOutcome)
73 {
74 this._navigationCaseImpl.setFromOutcome(fromOutcome);
75 return this;
76 }
77
78 @Override
79 public NavigationCaseBuilder toViewId(String toViewId)
80 {
81 this._navigationCaseImpl.setToViewId(toViewId);
82 return this;
83 }
84
85 @Override
86 public NavigationCaseBuilder toFlowDocumentId(String toFlowDocumentId)
87 {
88 this._navigationCaseImpl.setToFlowDocumentId(toFlowDocumentId);
89 return this;
90 }
91
92 @Override
93 public NavigationCaseBuilder condition(String condition)
94 {
95 this._navigationCaseImpl.setConditionExpression(null);
96 this._navigationCaseImpl.setCondition(condition);
97 return this;
98 }
99
100 @Override
101 public NavigationCaseBuilder condition(ValueExpression condition)
102 {
103 this._navigationCaseImpl.setCondition(null);
104 this._navigationCaseImpl.setConditionExpression(condition);
105 return this;
106 }
107
108 @Override
109 public RedirectBuilder redirect()
110 {
111 this._navigationCaseImpl.setRedirect(true);
112 return new RedirectBuilderImpl();
113 }
114
115 public class RedirectBuilderImpl extends RedirectBuilder
116 {
117
118 @Override
119 public RedirectBuilder parameter(String name, String value)
120 {
121
122 Map<String, List<String>> map = _navigationCaseImpl.getParameters();
123 if (map == null)
124 {
125 map = new HashMap<String, List<String>>();
126 _navigationCaseImpl.setParameters(map);
127 }
128 List<String> values = map.get(name);
129 if (values == null)
130 {
131 values = new ArrayList<String>();
132 map.put(name, values);
133 }
134 values.add(value);
135 return this;
136 }
137
138 @Override
139 public RedirectBuilder includeViewParams()
140 {
141 _navigationCaseImpl.setIncludeViewParams(true);
142 return this;
143 }
144
145 }
146 }