KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > jsfext > layout > descriptor > LayoutStaticText


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.tools.jsfext.layout.descriptor;
24
25 import com.sun.enterprise.tools.jsfext.component.ComponentUtil;
26
27 import java.io.IOException JavaDoc;
28
29 import javax.faces.context.FacesContext;
30 import javax.faces.context.ResponseWriter;
31 import javax.faces.component.UIComponent;
32 import javax.faces.el.ValueBinding;
33
34
35 /**
36  * <p> This class defines a LayoutStaticText. A LayoutStaticText describes a
37  * text to be output to the screen. This element is NOT a
38  * <code>UIComponent</code>.</p>
39  *
40  * @author Ken Paulsen (ken.paulsen@sun.com)
41  */

42 public class LayoutStaticText extends LayoutElementBase implements LayoutElement {
43
44     /**
45      * <p> Constructor.</p>
46      */

47     public LayoutStaticText(LayoutElement parent, String JavaDoc id, String JavaDoc value) {
48     super(parent, id);
49     _value = value;
50     }
51
52     /**
53      *
54      */

55     public String JavaDoc getValue() {
56     return _value;
57     }
58
59     /**
60      * <p> This method displays the text described by this component. If the
61      * text includes an EL expression, it will be evaluated. It returns
62      * false to avoid attempting to render children.</p>
63      *
64      * @param context The <code>FacesContext</code>
65      * @param component The <code>UIComponent</code>
66      *
67      * @return false
68      */

69     protected boolean encodeThis(FacesContext context, UIComponent component) throws IOException JavaDoc {
70     // Get the ResponseWriter
71
ResponseWriter writer = context.getResponseWriter();
72
73     // Render the child UIComponent
74
// if (staticText.isEscape()) {
75
// writer.writeText(getValue(), "value");
76
// } else {
77
// This code depends on the side-effect of Util.setOption
78
// converting the string to a ValueBinding if needed. The
79
// "__value" is arbitrary.
80
Object JavaDoc value = ComponentUtil.setOption(
81         context, "__value", getValue(),
82         getLayoutDefinition(), component);
83         if (value instanceof ValueBinding) {
84         value = ((ValueBinding) value).getValue(context);
85         }
86         if (value != null) {
87         writer.write(value.toString());
88         }
89 // }
90

91     // No children
92
return false;
93     }
94
95     private String JavaDoc _value = null;
96 }
97
Popular Tags