KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > taglib > core > VerbatimTag


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.renderkit.JSFAttr;
19 import org.apache.myfaces.taglib.UIComponentBodyTagBase;
20
21 import javax.faces.component.UIComponent;
22 import javax.faces.component.UIOutput;
23 import javax.servlet.jsp.JspException JavaDoc;
24 import javax.servlet.jsp.tagext.BodyContent JavaDoc;
25
26 /**
27  * @author Manfred Geiler (latest modification by $Author: matze $)
28  * @version $Revision: 1.11 $ $Date: 2004/10/13 11:51:00 $
29  */

30 public class VerbatimTag
31         extends UIComponentBodyTagBase
32 {
33     //private static final Log log = LogFactory.getLog(VerbatimTag.class);
34

35     public String JavaDoc getComponentType()
36     {
37         return "javax.faces.Output";
38     }
39
40     public String JavaDoc getRendererType()
41     {
42         return "javax.faces.Text";
43     }
44
45     // HtmlOutputText attributes
46
private String JavaDoc _escape;
47
48     protected void setProperties(UIComponent component)
49     {
50         super.setProperties(component);
51         if (_escape != null)
52         {
53             setBooleanProperty(component, JSFAttr.ESCAPE_ATTR, _escape);
54         }
55         else
56         {
57             //Default escape value for component is true, but for this tag it is false,
58
//so we must set it to false explicitly, if no attribute is given
59
component.getAttributes().put(JSFAttr.ESCAPE_ATTR, Boolean.FALSE);
60         }
61
62         //No need to save component state
63
component.setTransient(true);
64     }
65
66     public void setEscape(String JavaDoc escape)
67     {
68         _escape = escape;
69     }
70     
71     public int doAfterBody() throws JspException JavaDoc
72     {
73         BodyContent JavaDoc bodyContent = getBodyContent();
74         if (bodyContent != null)
75         {
76             UIOutput component = (UIOutput)getComponentInstance();
77             component.setValue(bodyContent.getString());
78         }
79         return super.doAfterBody();
80     }
81 }
82
Popular Tags