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.myfaces.shared_impl.renderkit.JSFAttr; |
22 | |
import org.apache.myfaces.shared_impl.taglib.html.HtmlCommandLinkELTagBase; |
23 | |
|
24 | |
import org.apache.commons.logging.Log; |
25 | |
import org.apache.commons.logging.LogFactory; |
26 | |
|
27 | |
import javax.faces.component.UIComponent; |
28 | |
import javax.faces.webapp.UIComponentBodyTag; |
29 | |
import javax.servlet.jsp.JspException; |
30 | |
import javax.servlet.jsp.tagext.BodyContent; |
31 | |
import java.io.IOException; |
32 | |
import java.io.Reader; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public abstract class UIComponentBodyTagBase |
40 | |
extends UIComponentBodyTag |
41 | |
{ |
42 | 0 | private static final Log log = LogFactory.getLog(UIComponentBodyTagBase.class); |
43 | |
|
44 | |
public int doEndTag() throws JspException |
45 | |
{ |
46 | 0 | if (log.isWarnEnabled()) |
47 | |
{ |
48 | 0 | UIComponent component = getComponentInstance(); |
49 | 0 | if (component != null && |
50 | |
component.getRendersChildren() && |
51 | |
!isBodyContentEmpty()) |
52 | |
{ |
53 | 0 | log.warn("Component with id '" + component.getClientId(getFacesContext()) + |
54 | |
"' (" + getClass().getName() + |
55 | |
" 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." + |
56 | |
"\n BodyContent:\n" + getBodyContent().getString().trim()); |
57 | |
} |
58 | |
} |
59 | 0 | return super.doEndTag(); |
60 | |
} |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
private boolean isBodyContentEmpty() |
66 | |
{ |
67 | 0 | BodyContent bodyContent = getBodyContent(); |
68 | 0 | if (bodyContent == null) |
69 | |
{ |
70 | 0 | return true; |
71 | |
} |
72 | |
try |
73 | |
{ |
74 | 0 | Reader reader = bodyContent.getReader(); |
75 | |
int c; |
76 | 0 | while ((c = reader.read()) != -1) |
77 | |
{ |
78 | 0 | if (!Character.isWhitespace((char)c)) |
79 | |
{ |
80 | 0 | return false; |
81 | |
} |
82 | |
} |
83 | 0 | return true; |
84 | |
} |
85 | 0 | catch (IOException e) |
86 | |
{ |
87 | 0 | log.error("Error inspecting BodyContent", e); |
88 | 0 | return false; |
89 | |
} |
90 | |
} |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
private String _forceId; |
96 | 0 | private String _forceIdIndex = "true"; |
97 | |
|
98 | |
|
99 | |
private String _value; |
100 | |
private String _converter; |
101 | |
|
102 | |
|
103 | |
protected void setProperties(UIComponent component) |
104 | |
{ |
105 | 0 | super.setProperties(component); |
106 | |
|
107 | 0 | setBooleanProperty(component, JSFAttr.FORCE_ID_ATTR, _forceId); |
108 | 0 | setBooleanProperty(component, org.apache.myfaces.shared_impl.renderkit.JSFAttr.FORCE_ID_INDEX_ATTR, _forceIdIndex); |
109 | |
|
110 | |
|
111 | |
|
112 | 0 | setValueProperty(component, _value); |
113 | 0 | setConverterProperty(component, _converter); |
114 | 0 | } |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
public void setForceId(String aForceId) |
124 | |
{ |
125 | 0 | _forceId = aForceId; |
126 | 0 | } |
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
public void setForceIdIndex(String aForceIdIndex) |
135 | |
{ |
136 | 0 | _forceIdIndex = aForceIdIndex; |
137 | 0 | } |
138 | |
|
139 | |
public void setValue(String value) |
140 | |
{ |
141 | 0 | _value = value; |
142 | 0 | } |
143 | |
|
144 | |
public void setConverter(String converter) |
145 | |
{ |
146 | 0 | _converter = converter; |
147 | 0 | } |
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
protected void setIntegerProperty(UIComponent component, String propName, String value) |
154 | |
{ |
155 | 0 | UIComponentTagUtils.setIntegerProperty(getFacesContext(), component, propName, value); |
156 | 0 | } |
157 | |
|
158 | |
protected void setStringProperty(UIComponent component, String propName, String value) |
159 | |
{ |
160 | 0 | UIComponentTagUtils.setStringProperty(getFacesContext(), component, propName, value); |
161 | 0 | } |
162 | |
|
163 | |
protected void setBooleanProperty(UIComponent component, String propName, String value) |
164 | |
{ |
165 | 0 | UIComponentTagUtils.setBooleanProperty(getFacesContext(), component, propName, value); |
166 | 0 | } |
167 | |
|
168 | |
protected void setValueProperty(UIComponent component, String value) |
169 | |
{ |
170 | 0 | UIComponentTagUtils.setValueProperty(getFacesContext(), component, value); |
171 | 0 | } |
172 | |
|
173 | |
private void setConverterProperty(UIComponent component, String value) |
174 | |
{ |
175 | 0 | UIComponentTagUtils.setConverterProperty(getFacesContext(), component, value); |
176 | 0 | } |
177 | |
|
178 | |
protected void setValidatorProperty(UIComponent component, String value) |
179 | |
{ |
180 | 0 | UIComponentTagUtils.setValidatorProperty(getFacesContext(), component, value); |
181 | 0 | } |
182 | |
|
183 | |
protected void setActionProperty(UIComponent component, String action) |
184 | |
{ |
185 | 0 | UIComponentTagUtils.setActionProperty(getFacesContext(), component, action); |
186 | 0 | } |
187 | |
|
188 | |
protected void setActionListenerProperty(UIComponent component, String actionListener) |
189 | |
{ |
190 | 0 | UIComponentTagUtils.setActionListenerProperty(getFacesContext(), component, actionListener); |
191 | 0 | } |
192 | |
|
193 | |
protected void setValueChangedListenerProperty(UIComponent component, String valueChangedListener) |
194 | |
{ |
195 | 0 | UIComponentTagUtils.setValueChangedListenerProperty(getFacesContext(), component, valueChangedListener); |
196 | 0 | } |
197 | |
|
198 | |
protected void setValueBinding(UIComponent component, |
199 | |
String propName, |
200 | |
String value) |
201 | |
{ |
202 | 0 | UIComponentTagUtils.setValueBinding(getFacesContext(), component, propName, value); |
203 | 0 | } |
204 | |
|
205 | |
} |