KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > tree > HtmlTreeCheckbox


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.tree;
17
18 import javax.faces.component.UISelectItem;
19 import javax.faces.context.FacesContext;
20 import javax.faces.el.ValueBinding;
21
22 /**
23  * @author <a HREF="mailto:dlestrat@yahoo.com">David Le Strat</a>
24  */

25 public class HtmlTreeCheckbox extends UISelectItem
26 {
27     /** The for attribute. */
28     private String JavaDoc forAttr = null;
29     
30     /** The for attribute declaration. */
31     public static final String JavaDoc FOR_ATTR = "for".intern();
32     
33     /** The component type. */
34     public static final String JavaDoc COMPONENT_TYPE = "org.apache.myfaces.HtmlTreeCheckbox";
35     
36     /** The component family. */
37     public static final String JavaDoc COMPONENT_FAMILY = "org.apache.myfaces.HtmlTreeCheckbox";
38     
39     /** The default renderer type. */
40     private static final String JavaDoc DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlTreeCheckbox";
41     
42     /**
43      * <p>
44      * Default Constructor.
45      * </p>
46      */

47     public HtmlTreeCheckbox()
48     {
49         setRendererType(DEFAULT_RENDERER_TYPE);
50     }
51     
52     /**
53      * @see javax.faces.component.UIComponent#getFamily()
54      */

55     public String JavaDoc getFamily()
56     {
57         return COMPONENT_FAMILY;
58     }
59     
60     /**
61      * @return The for attribute.
62      */

63     public String JavaDoc getFor()
64     {
65         if (forAttr != null) return forAttr;
66         ValueBinding vb = getValueBinding(FOR_ATTR);
67         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
68     }
69     
70     /**
71      * @param forAttr The for attribute.
72      */

73     public void setFor(String JavaDoc forAttr)
74     {
75         this.forAttr = forAttr;
76     }
77     
78     /**
79      * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
80      */

81     public Object JavaDoc saveState(FacesContext context)
82     {
83         Object JavaDoc values[] = new Object JavaDoc[2];
84         values[0] = super.saveState(context);
85         values[1] = forAttr;
86         return ((Object JavaDoc) (values));
87     }
88
89     /**
90      * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
91      */

92     public void restoreState(FacesContext context, Object JavaDoc state)
93     {
94         Object JavaDoc values[] = (Object JavaDoc[])state;
95         super.restoreState(context, values[0]);
96         forAttr = (String JavaDoc)values[1];
97     }
98
99 }
100
Popular Tags