KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > stylesheet > Stylesheet


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.custom.stylesheet;
17
18 import javax.faces.component.UIOutput;
19 import javax.faces.context.FacesContext;
20 import javax.faces.el.ValueBinding;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24
25
26 /**
27  * @author mwessendorf (latest modification by $Author: matze $)
28  * @version $Revision: 1.3 $ $Date: 2004/10/13 11:50:58 $
29  * $Log: Stylesheet.java,v $
30  * Revision 1.3 2004/10/13 11:50:58 matze
31  * renamed packages to org.apache
32  *
33  * Revision 1.2 2004/08/22 10:36:50 mwessendorf
34  * typo
35  *
36  * Revision 1.1 2004/08/18 15:36:09 mwessendorf
37  * added a new Stylesheet-Component
38  *
39 */

40
41 public class Stylesheet extends UIOutput {
42
43     public static final String JavaDoc COMPONENT_TYPE = "org.apache.myfaces.Stylesheet";
44     public static final String JavaDoc COMPONENT_FAMILY = "javax.faces.Output";
45     private static final String JavaDoc DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Stylesheet";
46     private static final Log log = LogFactory.getLog(Stylesheet.class);
47     
48     private String JavaDoc _path = null;
49     
50     
51     // ------------------------------------------------------------ Constructors
52
public Stylesheet() {
53
54         setRendererType(DEFAULT_RENDERER_TYPE);
55
56     }
57
58
59     public String JavaDoc getFamily() {
60
61         return COMPONENT_FAMILY;
62
63     }
64
65
66     public String JavaDoc getPath() {
67
68         if (_path != null) return _path;
69         ValueBinding vb = getValueBinding("path");
70         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
71     }
72
73     public void setPath(String JavaDoc path) {
74         this._path = path;
75     }
76
77     public void restoreState(FacesContext context, Object JavaDoc state) {
78
79         Object JavaDoc values[] = (Object JavaDoc[]) state;
80         super.restoreState(context, values[0]);
81         _path = (String JavaDoc) values[1];
82
83     }
84
85     public Object JavaDoc saveState(FacesContext context) {
86
87         Object JavaDoc values[] = new Object JavaDoc[2];
88         values[0] = super.saveState(context);
89         values[1] = _path;
90         return values;
91
92     }
93 }
Popular Tags