KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.IOException JavaDoc;
26
27 import javax.faces.context.FacesContext;
28 import javax.faces.context.ResponseWriter;
29 import javax.faces.component.UIComponent;
30
31
32 /**
33  * <p> This class defines a LayoutAttribute. A LayoutAttribute provides a
34  * means to write an attribute for the current markup tag. A markup tag
35  * must be started, but not yet closed for this to work.</p>
36  *
37  * @author Ken Paulsen (ken.paulsen@sun.com)
38  */

39 public class LayoutAttribute extends LayoutElementBase implements LayoutElement {
40
41     /**
42      * <p> Constructor.</p>
43      */

44     public LayoutAttribute(LayoutElement parent, String JavaDoc name, String JavaDoc value, String JavaDoc property) {
45     super(parent, name);
46     _name = name;
47     _value = value;
48     _property = property;
49     }
50
51     /**
52      *
53      */

54     public String JavaDoc getName() {
55     return _name;
56     }
57
58     /**
59      *
60      */

61     public String JavaDoc getValue() {
62     return _value;
63     }
64
65     /**
66      *
67      */

68     public String JavaDoc getProperty() {
69     return _property;
70     }
71
72     /**
73      * <p> This method displays the text described by this component. If the
74      * text includes an EL expression, it will be evaluated. It returns
75      * false to avoid attempting to render children.</p>
76      *
77      * @param context The <code>FacesContext</code>
78      * @param component The <code>UIComponent</code>
79      *
80      * @return false
81      */

82     protected boolean encodeThis(FacesContext context, UIComponent component) throws IOException JavaDoc {
83     // Get the ResponseWriter
84
ResponseWriter writer = context.getResponseWriter();
85
86     // Render...
87
Object JavaDoc value = resolveValue(context, component, getValue());
88     if ((value != null) && !value.toString().trim().equals("")) {
89         String JavaDoc name = getName();
90         String JavaDoc prop = getProperty();
91         if (prop == null) {
92         // Use the name if property is not supplied
93
prop = name;
94         } else if (prop.equals("null")) {
95         prop = null;
96         }
97         writer.writeAttribute(name, value, prop);
98     }
99
100     // No children
101
return false;
102     }
103
104     private String JavaDoc _name = null;
105     private String JavaDoc _value = null;
106     private String JavaDoc _property = null;
107 }
108
Popular Tags