KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Descriptions component that outputs descriptions held in a backing object
26  *
27  * @author gavinc
28  */

29 public class UIDescriptions extends SelfRenderingComponent
30 {
31    private Object JavaDoc value;
32    
33    /**
34     * @return Returns the object holding the decriptions
35     */

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

53    public void setValue(Object JavaDoc value)
54    {
55       this.value = value;
56    }
57
58    /**
59     * @see javax.faces.component.UIComponent#getFamily()
60     */

61    public String JavaDoc getFamily()
62    {
63       return "org.alfresco.faces.Descriptions";
64    }
65
66    /**
67     * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
68     */

69    public void restoreState(FacesContext context, Object JavaDoc state)
70    {
71       Object JavaDoc values[] = (Object JavaDoc[])state;
72       // standard component attributes are restored by the super class
73
super.restoreState(context, values[0]);
74       this.value = values[1];
75    }
76    
77    /**
78     * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
79     */

80    public Object JavaDoc saveState(FacesContext context)
81    {
82       Object JavaDoc values[] = new Object JavaDoc[2];
83       // standard component attributes are saved by the super class
84
values[0] = super.saveState(context);
85       values[1] = this.value;
86       return (values);
87    }
88 }
89
Popular Tags