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
21 package org.apache.shale.clay.component.chain;
22
23 import java.util.Map;
24 import java.util.TreeMap;
25
26 import javax.faces.component.UIComponent;
27 import javax.faces.context.FacesContext;
28
29 import org.apache.commons.chain.impl.ContextBase;
30 import org.apache.shale.clay.config.beans.AttributeBean;
31 import org.apache.shale.clay.config.beans.ComponentBean;
32
33 /***
34 * <p>This context is passed to all the commands in this package
35 * used to create the sub component tree for the clay component.
36 * The use of the context object promotes a reusable logic
37 * fragments that are loosely coupled and kind of snap togather.
38 * </p>
39 */
40 public class ClayContext extends ContextBase {
41
42 /***
43 * <p>Unique serialization id.</p>
44 */
45 private static final long serialVersionUID = 3618132372818901298L;
46
47 /***
48 * <p>Symbol table that holds literal strings that
49 * will be replaced within the value of an attribute.</p>
50 */
51 private Map symbols = null;
52
53 /***
54 * <p>Returns a Map containing replacement symbols
55 * within meta-component attributes.</p>
56 *
57 * @return map of {@link org.apache.shale.clay.config.beans.SymbolBean}
58 */
59 public Map getSymbols() {
60 if (symbols == null) {
61 symbols = new TreeMap();
62 }
63
64 return symbols;
65 }
66
67 /***
68 * <p>Sets a Map containing replacement symbols
69 * within meta-component attributes.</p>
70 *
71 * @param symbols map of {@link org.apache.shale.clay.config.beans.SymbolBean}
72 */
73 public void setSymbols(Map symbols) {
74 this.symbols = symbols;
75 }
76
77
78 /***
79 * <p>Unique identifier for a component metadata definition.</p>
80 */
81 private String jsfid = null;
82
83 /***
84 * <p>Returns the unique identifier for a component metadata definition.</p>
85 *
86 * @return jsfid
87 */
88 public String getJsfid() {
89 return jsfid;
90 }
91
92 /***
93 * <p>Sets the unique identifier for a component metadata definition.</p>
94 *
95 * @param jsfid unique component identifier
96 */
97 public void setJsfid(String jsfid) {
98 this.jsfid = jsfid;
99 }
100
101 /***
102 * <p>A <strong>child</strong> component is a faces Component, Validator,
103 * Listener or Converter that has a parent. Because a {@link org.apache.shale.clay.component.Clay} component
104 * is nested within a JSF/JSP page, it will should always have a parent.
105 * </p>
106 */
107 private Object child = null;
108
109 /***
110 * <b>Returns a child component that can be a UIComponent, Validator,
111 * Listener or Converter.
112 * </b>
113 *
114 * @return child component
115 */
116 public Object getChild() {
117 return child;
118 }
119
120 /***
121 * <p>Sets a child component that can be a UIComponent, Validator,
122 * Listener or Converter.
123 * </p>
124 *
125 * @param child component
126 */
127 public void setChild(Object child) {
128 this.child = child;
129 }
130
131 /***
132 * <p>The root of a {@link org.apache.shale.clay.component.Clay} component defined by a
133 * {@link org.apache.shale.clay.taglib.ClayTag} has a base metadata object of type
134 * {@link org.apache.shale.clay.config.beans.ComponentBean}. It can be defined in an XML
135 * file or dynamically built from a HTML fragment or defined
136 * at runtime.</p>
137 */
138 private ComponentBean rootElement = null;
139
140 /***
141 * <p>Returns the root config object used to construct the
142 * {@link org.apache.shale.clay.component.Clay} component subtree.
143 * </p>
144 *
145 * @return config bean
146 */
147 public ComponentBean getRootElement() {
148 return rootElement;
149 }
150
151 /***
152 * <p>Sets the root config object used to construct the
153 * {@link org.apache.shale.clay.component.Clay} component subtree.
154 * </p>
155 *
156 * @param rootElement parent config bean
157 */
158 public void setRootElement(ComponentBean rootElement) {
159 this.rootElement = rootElement;
160 }
161
162 /***
163 * <p>An attribute that is the current index in the
164 * <code>attributes</code> collection of the {@link org.apache.shale.clay.config.beans.ComponentBean}
165 * object. There are five <code>Command</code> object that use the
166 * <code>attribute</code> property in the context.
167 * <dl>
168 * <dd>{@link org.apache.shale.clay.component.chain.PropertyActionCommand}
169 * <dd>{@link org.apache.shale.clay.component.chain.PropertyActionListenerCommand}
170 * <dd>{@link org.apache.shale.clay.component.chain.PropertyValidatorCommand}
171 * <dd>{@link org.apache.shale.clay.component.chain.PropertyValueChangeListenerCommand}
172 * <dd>{@link org.apache.shale.clay.component.chain.PropertyValueCommand}
173 * </dl>
174 *
175 */
176 private AttributeBean attribute = null;
177
178 /***
179 * <p>Sets the current attribute for each in
180 * {@link org.apache.shale.clay.component.chain.AssignPropertiesCommand}.
181 * </p>
182 *
183 * @param attribute current attribute bean
184 */
185 public void setAttribute(AttributeBean attribute) {
186 this.attribute = attribute;
187 }
188
189 /***
190 * <p>Gets the current attribute for each in
191 * {@link org.apache.shale.clay.component.chain.AssignPropertiesCommand}.
192 * </p>
193 *
194 * @return current attribute bean
195 */
196 public AttributeBean getAttribute() {
197 return attribute;
198 }
199
200 /***
201 * <p>Represents the current component metadata used to build
202 * an associated JSF resource.</p>
203 */
204 private ComponentBean displayElement = null;
205
206 /***
207 * <p>Returns the current component metadata used to build
208 * a JSF resource.
209 * </p>
210 *
211 * @return current config bean
212 */
213 public ComponentBean getDisplayElement() {
214 return displayElement;
215 }
216
217 /***
218 * <p>Sets the current component metadata used to build
219 * a JSF resource.
220 * </p>
221 *
222 * @param displayElement config bean
223 */
224 public void setDisplayElement(ComponentBean displayElement) {
225 this.displayElement = displayElement;
226 }
227
228 /***
229 * <p>Reference to the current {@link FacesContext}.</p>
230 */
231 private FacesContext facesContext = null;
232
233 /***
234 * <p>Returns the current faces Context.</p>
235 *
236 * @return faces context
237 */
238 public FacesContext getFacesContext() {
239 return facesContext;
240 }
241
242 /***
243 * <p>Sets the current faces Context.</p>
244 *
245 * @param facesContext jsf context
246 */
247 public void setFacesContext(FacesContext facesContext) {
248 this.facesContext = facesContext;
249 }
250
251 /***
252 * <p>The <strong>parent</strong> of the <strong>child</strong>
253 * component. The <strong>parent</strong> can be something other
254 * than a subclass of <code>UIComponent</code>.
255 * </p>
256 */
257 private UIComponent parent = null;
258
259 /***
260 * <p>Returns the <strong>parent</strong> of the <strong>child</strong>.</p>
261 *
262 * @return current parent component
263 */
264 public UIComponent getParent() {
265 return parent;
266 }
267
268 /***
269 * <p>Sets the <strong>parent</strong> of the <strong>child</strong>.</p>
270 *
271 * @param parent current
272 */
273 public void setParent(UIComponent parent) {
274 this.parent = parent;
275 }
276
277 /***
278 * <p>Index at which a new component must be added in the list of childs.</p>
279 */
280 private int childIndex = 0;
281
282 /***
283 * <p>Returns the index at which a new component must be added in the list
284 * of childs.</p>
285 *
286 * @return current child index
287 */
288 public int getChildIndex() {
289 return childIndex;
290 }
291
292 /***
293 * <p>Sets the index at which a new component must be added in the list
294 * of childs.</p>
295 *
296 * @param index current child index
297 */
298 public void setChildIndex(int index) {
299 childIndex = index;
300 }
301 }