1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.shared_impl.taglib; |
20 | |
|
21 | |
import org.apache.commons.logging.Log; |
22 | |
import org.apache.commons.logging.LogFactory; |
23 | |
|
24 | |
import javax.el.MethodExpression; |
25 | |
import javax.el.ValueExpression; |
26 | |
import javax.faces.component.UIComponent; |
27 | |
import javax.faces.webapp.UIComponentELTag; |
28 | |
import javax.servlet.jsp.JspException; |
29 | |
import javax.servlet.jsp.tagext.BodyContent; |
30 | |
import java.io.IOException; |
31 | |
import java.io.Reader; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public abstract class UIComponentBodyELTagBase extends UIComponentELTag |
38 | |
{ |
39 | 0 | private static final Log log = LogFactory.getLog(UIComponentBodyTagBase.class); |
40 | |
|
41 | |
public int doEndTag() throws JspException |
42 | |
{ |
43 | 0 | if (log.isWarnEnabled()) |
44 | |
{ |
45 | 0 | UIComponent component = getComponentInstance(); |
46 | 0 | if (component != null && |
47 | |
component.getRendersChildren() && |
48 | |
!isBodyContentEmpty()) |
49 | |
{ |
50 | 0 | log.warn("Component with id '" + component.getClientId(getFacesContext()) + |
51 | |
"' (" + getClass().getName() + |
52 | |
" tag) and path : "+org.apache.myfaces.shared_impl.renderkit.RendererUtils.getPathToComponent(component)+"renders it's children, but has embedded JSP or HTML code. Use the <f:verbatim> tag for nested HTML. For comments use <%/* */%> style JSP comments instead of <!-- --> style HTML comments." + |
53 | |
"\n BodyContent:\n" + getBodyContent().getString().trim()); |
54 | |
} |
55 | |
} |
56 | 0 | return super.doEndTag(); |
57 | |
} |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
private boolean isBodyContentEmpty() |
63 | |
{ |
64 | 0 | BodyContent bodyContent = getBodyContent(); |
65 | 0 | if (bodyContent == null) |
66 | |
{ |
67 | 0 | return true; |
68 | |
} |
69 | |
try |
70 | |
{ |
71 | 0 | Reader reader = bodyContent.getReader(); |
72 | |
int c; |
73 | 0 | while ((c = reader.read()) != -1) |
74 | |
{ |
75 | 0 | if (!Character.isWhitespace((char)c)) |
76 | |
{ |
77 | 0 | return false; |
78 | |
} |
79 | |
} |
80 | 0 | return true; |
81 | |
} |
82 | 0 | catch (IOException e) |
83 | |
{ |
84 | 0 | log.error("Error inspecting BodyContent", e); |
85 | 0 | return false; |
86 | |
} |
87 | |
} |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
private ValueExpression _forceId; |
93 | |
private ValueExpression _forceIdIndex; |
94 | 0 | private static final Boolean DEFAULT_FORCE_ID_INDEX_VALUE = Boolean.TRUE; |
95 | |
|
96 | |
|
97 | |
private ValueExpression _value; |
98 | |
private ValueExpression _converter; |
99 | |
|
100 | |
|
101 | |
protected void setProperties(UIComponent component) |
102 | |
{ |
103 | 0 | super.setProperties(component); |
104 | |
|
105 | 0 | setBooleanProperty(component, org.apache.myfaces.shared_impl.renderkit.JSFAttr.FORCE_ID_ATTR, _forceId); |
106 | 0 | setBooleanProperty(component, org.apache.myfaces.shared_impl.renderkit.JSFAttr.FORCE_ID_INDEX_ATTR, _forceIdIndex, DEFAULT_FORCE_ID_INDEX_VALUE); |
107 | |
|
108 | |
|
109 | |
|
110 | 0 | setValueProperty(component, _value); |
111 | 0 | setConverterProperty(component, _converter); |
112 | 0 | } |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
public void setForceId(ValueExpression aForceId) |
122 | |
{ |
123 | 0 | _forceId = aForceId; |
124 | 0 | } |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
public void setForceIdIndex(ValueExpression aForceIdIndex) |
133 | |
{ |
134 | 0 | _forceIdIndex = aForceIdIndex; |
135 | 0 | } |
136 | |
|
137 | |
public void setValue(ValueExpression value) |
138 | |
{ |
139 | 0 | _value = value; |
140 | 0 | } |
141 | |
|
142 | |
public void setConverter(ValueExpression converter) |
143 | |
{ |
144 | 0 | _converter = converter; |
145 | 0 | } |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
protected void setIntegerProperty(UIComponent component, String propName, ValueExpression value) |
152 | |
{ |
153 | 0 | UIComponentELTagUtils.setIntegerProperty(component, propName, value); |
154 | 0 | } |
155 | |
|
156 | |
@Deprecated |
157 | |
protected void setIntegerProperty(UIComponent component, String propName, String value) |
158 | |
{ |
159 | 0 | UIComponentTagUtils.setIntegerProperty(getFacesContext(), component, propName, value); |
160 | 0 | } |
161 | |
|
162 | |
protected void setStringProperty(UIComponent component, String propName, ValueExpression value) |
163 | |
{ |
164 | 0 | UIComponentELTagUtils.setStringProperty(component, propName, value); |
165 | 0 | } |
166 | |
|
167 | |
@Deprecated |
168 | |
protected void setStringProperty(UIComponent component, String propName, String value) |
169 | |
{ |
170 | 0 | UIComponentTagUtils.setStringProperty(getFacesContext(), component, propName, value); |
171 | 0 | } |
172 | |
|
173 | |
protected void setBooleanProperty(UIComponent component, String propName, ValueExpression value) |
174 | |
{ |
175 | 0 | UIComponentELTagUtils.setBooleanProperty(component, propName, value); |
176 | 0 | } |
177 | |
|
178 | |
protected void setBooleanProperty(UIComponent component, String propName, ValueExpression value, Boolean defaultValue) |
179 | |
{ |
180 | 0 | UIComponentELTagUtils.setBooleanProperty(component, propName, value, defaultValue); |
181 | 0 | } |
182 | |
|
183 | |
@Deprecated |
184 | |
protected void setBooleanProperty(UIComponent component, String propName, String value) |
185 | |
{ |
186 | 0 | UIComponentTagUtils.setBooleanProperty(getFacesContext(), component, propName, value); |
187 | 0 | } |
188 | |
|
189 | |
private void setValueProperty(UIComponent component, ValueExpression value) |
190 | |
{ |
191 | 0 | UIComponentELTagUtils.setValueProperty(getFacesContext(), component, value); |
192 | 0 | } |
193 | |
|
194 | |
@Deprecated |
195 | |
protected void setValueProperty(UIComponent component, String value) |
196 | |
{ |
197 | 0 | UIComponentTagUtils.setValueProperty(getFacesContext(), component, value); |
198 | 0 | } |
199 | |
|
200 | |
private void setConverterProperty(UIComponent component, ValueExpression value) |
201 | |
{ |
202 | 0 | UIComponentELTagUtils.setConverterProperty(getFacesContext(), component, value); |
203 | 0 | } |
204 | |
|
205 | |
|
206 | |
@Deprecated |
207 | |
private void setConverterProperty(UIComponent component, String value) |
208 | |
{ |
209 | 0 | UIComponentTagUtils.setConverterProperty(getFacesContext(), component, value); |
210 | 0 | } |
211 | |
|
212 | |
protected void addValidatorProperty(UIComponent component, MethodExpression value) |
213 | |
{ |
214 | 0 | UIComponentELTagUtils.addValidatorProperty(getFacesContext(), component, value); |
215 | 0 | } |
216 | |
|
217 | |
@Deprecated |
218 | |
protected void setValidatorProperty(UIComponent component, String value) |
219 | |
{ |
220 | 0 | UIComponentTagUtils.setValidatorProperty(getFacesContext(), component, value); |
221 | 0 | } |
222 | |
|
223 | |
protected void setActionProperty(UIComponent component, MethodExpression action) |
224 | |
{ |
225 | 0 | UIComponentELTagUtils.setActionProperty(getFacesContext(), component, action); |
226 | 0 | } |
227 | |
|
228 | |
@Deprecated |
229 | |
protected void setActionProperty(UIComponent component, String action) |
230 | |
{ |
231 | 0 | UIComponentTagUtils.setActionProperty(getFacesContext(), component, action); |
232 | 0 | } |
233 | |
|
234 | |
protected void setActionListenerProperty(UIComponent component, MethodExpression actionListener) |
235 | |
{ |
236 | 0 | UIComponentELTagUtils.addActionListenerProperty(getFacesContext(), component, actionListener); |
237 | 0 | } |
238 | |
|
239 | |
@Deprecated |
240 | |
protected void setActionListenerProperty(UIComponent component, String actionListener) |
241 | |
{ |
242 | 0 | UIComponentTagUtils.setActionListenerProperty(getFacesContext(), component, actionListener); |
243 | 0 | } |
244 | |
|
245 | |
protected void addValueChangedListenerProperty(UIComponent component, MethodExpression valueChangedListener) |
246 | |
{ |
247 | 0 | UIComponentELTagUtils.addValueChangedListenerProperty(getFacesContext(), component, valueChangedListener); |
248 | 0 | } |
249 | |
|
250 | |
@Deprecated |
251 | |
protected void setValueChangedListenerProperty(UIComponent component, String valueChangedListener) |
252 | |
{ |
253 | 0 | UIComponentTagUtils.setValueChangedListenerProperty(getFacesContext(), component, valueChangedListener); |
254 | 0 | } |
255 | |
|
256 | |
protected void setValueBinding(UIComponent component, |
257 | |
String propName, |
258 | |
ValueExpression value) |
259 | |
{ |
260 | 0 | UIComponentELTagUtils.setValueBinding(getFacesContext(), component, propName, value); |
261 | 0 | } |
262 | |
|
263 | |
} |