01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.myfaces.taglib.core;
17:
18: import org.apache.myfaces.shared_impl.renderkit.JSFAttr;
19: import org.apache.myfaces.shared_impl.taglib.UIComponentELTagBase;
20:
21: import javax.el.ValueExpression;
22: import javax.faces.component.UIComponent;
23: import javax.faces.component.UIOutput;
24: import javax.servlet.jsp.JspException;
25: import javax.servlet.jsp.tagext.BodyContent;
26:
27: /**
28: * @author Manfred Geiler (latest modification by $Author: baranda $)
29: * @version $Revision: 539220 $ $Date: 2007-05-18 04:14:37 +0200 (Fr, 18 Mai 2007) $
30: */
31: public class VerbatimTag extends UIComponentELTagBase {
32: //private static final Log log = LogFactory.getLog(VerbatimTag.class);
33:
34: public String getComponentType() {
35: return "javax.faces.Output";
36: }
37:
38: public String getRendererType() {
39: return "javax.faces.Text";
40: }
41:
42: // HtmlOutputText attributes
43: private ValueExpression _escape;
44: private ValueExpression _rendered;
45:
46: protected void setProperties(UIComponent component) {
47: super .setProperties(component);
48:
49: setBooleanProperty(component, JSFAttr.ESCAPE_ATTR, _escape,
50: Boolean.FALSE);
51: setBooleanProperty(component, JSFAttr.RENDERED, _rendered,
52: Boolean.TRUE);
53:
54: //No need to save component state
55: component.setTransient(true);
56: }
57:
58: public void setEscape(ValueExpression escape) {
59: _escape = escape;
60: }
61:
62: public void setRendered(ValueExpression rendered) {
63: _rendered = rendered;
64: }
65:
66: public int doAfterBody() throws JspException {
67: BodyContent bodyContent = getBodyContent();
68: if (bodyContent != null) {
69: UIOutput component = (UIOutput) getComponentInstance();
70: component.setValue(bodyContent.getString());
71: bodyContent.clearBody();
72: }
73: return super.getDoAfterBodyValue();
74: }
75: }
|