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.taglib;
22
23 import javax.faces.component.UIComponent;
24 import javax.faces.context.FacesContext;
25 import javax.faces.el.ValueBinding;
26 import javax.faces.webapp.UIComponentBodyTag;
27
28 import org.apache.shale.clay.component.Clay;
29
30 /***
31 * <p>JSP Tag for the {@link org.apache.shale.clay.component.Clay} component.</p>
32 *
33 */
34 public class ClayTag extends UIComponentBodyTag {
35
36 /***
37 * <p>Represents the meta-component to build the subtree on.</p>
38 */
39 private String jsfid = null;
40
41 /***
42 * <p>The name of the managed bean instance in the faces configuration file that
43 * should be bound to this view composition. The literal "@managed-bean-name"
44 * in the component metadata will be replaced with this value before the
45 * binding of the expression is created.
46 * </p>
47 */
48 private String managedBeanName = null;
49
50 /***
51 * <p>A method event that conforms to the standard <code>validator</code>
52 * attribute. This event will get fired before the sub component tree is
53 * build.
54 * </p>
55 */
56 private String shapeValidator = null;
57
58 /***
59 * <p>Returns the expression literal defining the validator event method
60 * binding.
61 * </p>
62 *
63 * @return method binding expression
64 */
65 public String getShapeValidator() {
66 return shapeValidator;
67 }
68
69 /***
70 * <p>Sets the expression literal defining the validator event method binding.
71 * </p>
72 *
73 * @param shapeValidator <code>String</code> validator binding expression
74 */
75 public void setShapeValidator(String shapeValidator) {
76 this.shapeValidator = shapeValidator;
77 }
78
79
80 /***
81 * <p>Gets the display Element identifier to be rendered.</p>
82 *
83 * @return jsfid
84 */
85 public String getJsfid() {
86 return jsfid;
87 }
88
89 /***
90 * <p>Sets the identifier defining component metadata.
91 * </p>
92 *
93 * @param jsfid <code>String</code> sets the component element to be rendered
94 */
95 public void setJsfid(String jsfid) {
96 this.jsfid = jsfid;
97 }
98
99 /***
100 * <p>Gets the name of the managed bean that is dynamically resolved
101 * using a token replacement before binding the value expression.
102 * If not explicitly set, it will default to the literal <code>UNKNOWN</code>
103 * </p>
104 *
105 * @return managed bean name symbol
106 */
107 public String getManagedBeanName() {
108 if (managedBeanName == null || managedBeanName.length() == 0) {
109 return "UNKNOWN";
110 }
111
112 return managedBeanName;
113 }
114
115 /***
116 * <p> Name of the managed bean that is dynamically resolved. The literal
117 * string "managed-bean-name" is replaced with the value of this
118 * property.
119 * </p>
120 *
121 * @param managedBeanName <code>String</code>
122 */
123 public void setManagedBeanName(String managedBeanName) {
124 this.managedBeanName = managedBeanName;
125 }
126
127
128 /***
129 * <p> Returns the logical component name registered in the faces config
130 * for the {@link org.apache.shale.clay.component.Clay} component.
131 * </p>
132 *
133 * @return component type
134 * @see javax.faces.webapp.UIComponentTag#getComponentType()
135 */
136 public String getComponentType() {
137 return "org.apache.shale.clay.component.Clay";
138 }
139
140 /***
141 * <p>Returns the render registered for the component. The
142 * {@link org.apache.shale.clay.component.Clay} component doesn't
143 * have a render because the component invokes the rendering of
144 * it's children.
145 * </p>
146 *
147 * @return <code>null</code>
148 * @see javax.faces.webapp.UIComponentTag#getRendererType()
149 */
150 public String getRendererType() {
151 return null;
152 }
153
154 /***
155 * <p>This method is invoked by the super and its purpose it
156 * to push tag attributes to corresponding component property
157 * values.
158 * </p>
159 *
160 * @param component {@link UIComponent} instance of {@link org.apache.shale.clay.component.Clay}
161 */
162 protected void setProperties(UIComponent component) {
163 super.setProperties(component);
164
165 Clay c = (Clay) component;
166 FacesContext facesContext = getFacesContext();
167
168 if (getJsfid() != null) {
169
170 c.setJsfid(getJsfid());
171
172 }
173
174
175 if (getManagedBeanName() != null) {
176 c.setManagedBeanName(getManagedBeanName());
177
178 if (isValueReference(getManagedBeanName())) {
179 ValueBinding valueBinding = facesContext.getApplication().createValueBinding(getManagedBeanName());
180 Object value = valueBinding.getValue(facesContext);
181 c.setManagedBeanName((value != null) ? value.toString() : null);
182
183 } else {
184 c.setManagedBeanName(getManagedBeanName());
185 }
186
187 }
188
189
190 if (getShapeValidator() != null) {
191 c.setShapeValidator(getShapeValidator());
192 }
193
194 }
195 }