KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > ui > common > component > description > UIDescription


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.web.ui.common.component.description;
18
19 import javax.faces.context.FacesContext;
20 import javax.faces.el.ValueBinding;
21
22 import org.alfresco.web.ui.common.component.SelfRenderingComponent;
23
24 /**
25  * Description component that outputs a dynamic description
26  *
27  * @author gavinc
28  */

29 public class UIDescription extends SelfRenderingComponent
30 {
31    private String JavaDoc controlValue;
32    private String JavaDoc text;
33
34    /**
35     * @return The control value the description is for
36     */

37    public String JavaDoc getControlValue()
38    {
39       if (this.controlValue == null)
40       {
41          ValueBinding vb = getValueBinding("controlValue");
42          if (vb != null)
43          {
44             this.controlValue = (String JavaDoc)vb.getValue(getFacesContext());
45          }
46       }
47       
48       return this.controlValue;
49    }
50
51    /**
52     * @param controlValue Sets the control value this description is for
53     */

54    public void setControlValue(String JavaDoc controlValue)
55    {
56       this.controlValue = controlValue;
57    }
58
59    /**
60     * @return Returns the description text
61     */

62    public String JavaDoc getText()
63    {
64       if (this.text == null)
65       {
66          ValueBinding vb = getValueBinding("text");
67          if (vb != null)
68          {
69             this.text = (String JavaDoc)vb.getValue(getFacesContext());
70          }
71       }
72       
73       return this.text;
74    }
75
76    /**
77     * @param text Sets the description text
78     */

79    public void setText(String JavaDoc text)
80    {
81       this.text = text;
82    }
83
84    /**
85     * @see javax.faces.component.UIComponent#getFamily()
86     */

87    public String JavaDoc getFamily()
88    {
89       return "org.alfresco.faces.Description";
90    }
91
92    /**
93     * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
94     */

95    public void restoreState(FacesContext context, Object JavaDoc state)
96    {
97       Object JavaDoc values[] = (Object JavaDoc[])state;
98       // standard component attributes are restored by the super class
99
super.restoreState(context, values[0]);
100       this.controlValue = (String JavaDoc)values[1];
101       this.text = (String JavaDoc)values[2];
102    }
103    
104    /**
105     * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
106     */

107    public Object JavaDoc saveState(FacesContext context)
108    {
109       Object JavaDoc values[] = new Object JavaDoc[3];
110       // standard component attributes are saved by the super class
111
values[0] = super.saveState(context);
112       values[1] = this.controlValue;
113       values[2] = this.text;
114       return (values);
115    }
116
117    /**
118     * @see javax.faces.component.UIComponent#getRendersChildren()
119     */

120    public boolean getRendersChildren()
121    {
122       return false;
123    }
124 }
125
Popular Tags