KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > radio > HtmlRadio


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.radio;
17
18 import javax.faces.component.UIComponentBase;
19 import javax.faces.context.FacesContext;
20 import javax.faces.el.ValueBinding;
21
22 /**
23  * @author Thomas Spiegl (latest modification by $Author: manolito $)
24  * @version $Revision: 1.8 $ $Date: 2005/04/13 12:48:46 $
25  * $Log: HtmlRadio.java,v $
26  * Revision 1.8 2005/04/13 12:48:46 manolito
27  * MYFACES-186 x:radio and x:checkbox cause ClassCastException
28  * Since the proposed fix is within generated code block, I had to fix the generator instead!
29  *
30  * Revision 1.7 2004/10/13 11:50:57 matze
31  * renamed packages to org.apache
32  *
33  * Revision 1.6 2004/07/01 21:53:08 mwessendorf
34  * ASF switch
35  *
36  * Revision 1.5 2004/04/02 13:57:10 manolito
37  * extended HtmlSelectManyCheckbox with layout "spread" and custom Checkbox component
38  *
39  * Revision 1.4 2004/03/31 15:15:58 royalts
40  * no message
41  *
42  * Revision 1.3 2004/03/31 13:43:30 royalts
43  * no message
44  *
45  * Revision 1.2 2004/03/31 13:26:07 manolito
46  * extended radio renderer
47  *
48  */

49 public class HtmlRadio
50     extends UIComponentBase
51 {
52     //private static final Log log = LogFactory.getLog(HtmlRadio.class);
53

54     public static final String JavaDoc FOR_ATTR = "for".intern();
55     public static final String JavaDoc INDEX_ATTR = "index".intern();
56
57
58     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
59

60     public static final String JavaDoc COMPONENT_TYPE = "org.apache.myfaces.HtmlRadio";
61     public static final String JavaDoc COMPONENT_FAMILY = "org.apache.myfaces.Radio";
62     private static final String JavaDoc DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Radio";
63
64     private String JavaDoc _for = null;
65     private Integer JavaDoc _index = null;
66
67     public HtmlRadio()
68     {
69         setRendererType(DEFAULT_RENDERER_TYPE);
70     }
71
72     public String JavaDoc getFamily()
73     {
74         return COMPONENT_FAMILY;
75     }
76
77     public void setFor(String JavaDoc forValue)
78     {
79         _for = forValue;
80     }
81
82     public String JavaDoc getFor()
83     {
84         if (_for != null) return _for;
85         ValueBinding vb = getValueBinding("for");
86         return vb != null ? (String JavaDoc)vb.getValue(getFacesContext()) : null;
87     }
88
89     public void setIndex(int index)
90     {
91         _index = new Integer JavaDoc(index);
92     }
93
94     public int getIndex()
95     {
96         if (_index != null) return _index.intValue();
97         ValueBinding vb = getValueBinding("index");
98         Number JavaDoc v = vb != null ? (Number JavaDoc)vb.getValue(getFacesContext()) : null;
99         return v != null ? v.intValue() : Integer.MIN_VALUE;
100     }
101
102
103
104     public Object JavaDoc saveState(FacesContext context)
105     {
106         Object JavaDoc values[] = new Object JavaDoc[3];
107         values[0] = super.saveState(context);
108         values[1] = _for;
109         values[2] = _index;
110         return ((Object JavaDoc) (values));
111     }
112
113     public void restoreState(FacesContext context, Object JavaDoc state)
114     {
115         Object JavaDoc values[] = (Object JavaDoc[])state;
116         super.restoreState(context, values[0]);
117         _for = (String JavaDoc)values[1];
118         _index = (Integer JavaDoc)values[2];
119     }
120     //------------------ GENERATED CODE END ---------------------------------------
121

122 }
123
Popular Tags