KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > collapsiblepanel > HtmlCollapsiblePanel


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.collapsiblepanel;
17
18 import javax.faces.component.html.HtmlPanelGroup;
19 import javax.faces.context.FacesContext;
20 import javax.faces.el.ValueBinding;
21
22 /**
23  * @author Kalle Korhonen (latest modification by $Author: matzew $)
24  *
25  * @version $Revision: 1.1 $ $Date: 2005/01/10 08:22:17 $
26  *
27  */

28 public class HtmlCollapsiblePanel extends HtmlPanelGroup
29 {
30     //private static final Log log = LogFactory.getLog(HtmlCollapsiblePanel.class);
31

32     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
33
private static final boolean DEFAULT_COLLAPSED = true;
34
35     public static final String JavaDoc COMPONENT_TYPE = "org.apache.myfaces.HtmlCollapsiblePanel";
36     public static final String JavaDoc COMPONENT_FAMILY = "javax.faces.Panel";
37     private static final String JavaDoc DEFAULT_RENDERER_TYPE = "org.apache.myfaces.CollapsiblePanel";
38
39     private Boolean JavaDoc _collapsed = null;
40     private String JavaDoc _value = null;
41     
42     public HtmlCollapsiblePanel()
43     {
44         setRendererType(DEFAULT_RENDERER_TYPE);
45     }
46
47     public String JavaDoc getFamily()
48     {
49         return COMPONENT_FAMILY;
50     }
51
52     public void setCollapsed(boolean collapsed)
53     {
54         _collapsed = new Boolean JavaDoc(collapsed);
55     }
56
57     public boolean isCollapsed()
58     {
59         if (_collapsed != null) return _collapsed.booleanValue();
60         ValueBinding vb = getValueBinding("collapsed");
61         Boolean JavaDoc v = vb != null ? (Boolean JavaDoc)vb.getValue(getFacesContext()) : null;
62         return v != null ? v.booleanValue() : DEFAULT_COLLAPSED;
63     }
64     
65     public void setValue(String JavaDoc value)
66     {
67         _value = value;
68     }
69
70     public String JavaDoc getValue()
71     {
72         if (_value != null) return _value;
73         ValueBinding vb = getValueBinding("value");
74         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
75     }
76
77     public Object JavaDoc saveState(FacesContext context)
78     {
79         Object JavaDoc values[] = new Object JavaDoc[3];
80         values[0] = super.saveState(context);
81         values[1] = _collapsed;
82         values[2] = _value;
83         return ((Object JavaDoc) (values));
84     }
85
86     public void restoreState(FacesContext context, Object JavaDoc state)
87     {
88           Object JavaDoc values[] = (Object JavaDoc[])state;
89         super.restoreState(context, values[0]);
90         _collapsed = (Boolean JavaDoc)values[1];
91         _value = (String JavaDoc)values[2];
92     }
93     //------------------ GENERATED CODE END ---------------------------------------
94
}
95
Popular Tags