KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > ui > common > tag > PanelTag


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.tag;
18
19 import javax.faces.FacesException;
20 import javax.faces.component.UICommand;
21 import javax.faces.component.UIComponent;
22 import javax.faces.el.MethodBinding;
23 import javax.servlet.jsp.JspException JavaDoc;
24
25 import org.alfresco.web.ui.common.component.UIPanel;
26
27 /**
28  * @author kevinr
29  */

30 public class PanelTag extends HtmlComponentTag
31 {
32    /**
33     * @see javax.faces.webapp.UIComponentTag#getComponentType()
34     */

35    public String JavaDoc getComponentType()
36    {
37       return "org.alfresco.faces.Panel";
38    }
39
40    /**
41     * @see javax.faces.webapp.UIComponentTag#getRendererType()
42     */

43    public String JavaDoc getRendererType()
44    {
45       // the component is self renderering
46
return null;
47    }
48
49    /**
50     * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
51     */

52    protected void setProperties(UIComponent component)
53    {
54       super.setProperties(component);
55       
56       setStringProperty(component, "label", this.label);
57       setStringProperty(component, "border", this.border);
58       setBooleanProperty(component, "progressive", this.progressive);
59       setStringProperty(component, "bgcolor", this.bgcolor);
60       setStringProperty(component, "titleBorder", this.titleBorder);
61       setStringProperty(component, "titleBgcolor", this.titleBgcolor);
62       setBooleanProperty(component, "expanded", this.expanded);
63       setStringProperty(component, "facetsId", this.facetsId);
64       if (expandedActionListener != null)
65       {
66          if (isValueReference(expandedActionListener))
67          {
68             MethodBinding vb = getFacesContext().getApplication().createMethodBinding(expandedActionListener, ACTION_CLASS_ARGS);
69             ((UIPanel)component).setExpandedActionListener(vb);
70          }
71          else
72          {
73             throw new FacesException("Expanded Action listener method binding incorrectly specified: " + expandedActionListener);
74          }
75       }
76    }
77    
78    /**
79     * @see javax.servlet.jsp.tagext.Tag#release()
80     */

81    public void release()
82    {
83       super.release();
84       this.label = null;
85       this.border = null;
86       this.progressive = null;
87       this.bgcolor = null;
88       this.expanded = null;
89       this.expandedActionListener = null;
90       this.facetsId = null;
91    }
92    
93    /**
94     * Override this to allow the panel component to control whether child components
95     * are rendered by the JSP tag framework. This is a nasty solution as it requires
96     * a reference to the UIPanel instance and also specific knowledge of the component
97     * type that is created by the framework for this tag.
98     *
99     * The reason for this solution is to allow any child content (including HTML tags)
100     * to be displayed inside the UIPanel component without having to resort to the
101     * awful JSF Component getRendersChildren() mechanism - as this would force the use
102     * of the verbatim tags for ALL non-JSF child content!
103     */

104    protected int getDoStartValue() throws JspException JavaDoc
105    {
106       UIComponent component = getComponentInstance();
107       if (component instanceof UIPanel)
108       {
109          if (((UIPanel)component).isExpanded() == true && component.isRendered() == true)
110          {
111             return EVAL_BODY_INCLUDE;
112          }
113          else
114          {
115             return SKIP_BODY;
116          }
117       }
118       return EVAL_BODY_INCLUDE;
119    }
120
121    /**
122     * Set the border
123     *
124     * @param border the border
125     */

126    public void setBorder(String JavaDoc border)
127    {
128       this.border = border;
129    }
130
131    /**
132     * Set the progressive
133     *
134     * @param progressive the progressive
135     */

136    public void setProgressive(String JavaDoc progressive)
137    {
138       this.progressive = progressive;
139    }
140
141    /**
142     * Set the label
143     *
144     * @param label the label
145     */

146    public void setLabel(String JavaDoc label)
147    {
148       this.label = label;
149    }
150
151    /**
152     * Set the bgcolor
153     *
154     * @param bgcolor the bgcolor
155     */

156    public void setBgcolor(String JavaDoc bgcolor)
157    {
158       this.bgcolor = bgcolor;
159    }
160    
161    /**
162     * @param titleBgcolor The title area background color
163     */

164    public void setTitleBgcolor(String JavaDoc titleBgcolor)
165    {
166       this.titleBgcolor = titleBgcolor;
167    }
168
169    /**
170     * @param titleBorder The title area border style
171     */

172    public void setTitleBorder(String JavaDoc titleBorder)
173    {
174       this.titleBorder = titleBorder;
175    }
176
177    /**
178     * Set whether the panel is expanded, default is true.
179     *
180     * @param expanded the expanded flag
181     */

182    public void setExpanded(String JavaDoc expanded)
183    {
184       this.expanded = expanded;
185    }
186
187    /**
188     * Set the expandedActionListener
189     *
190     * @param expandedActionListener the expandedActionListener
191     */

192    public void setExpandedActionListener(String JavaDoc expandedActionListener)
193    {
194       this.expandedActionListener = expandedActionListener;
195    }
196
197    /**
198     * Set the facetsId
199     *
200     * @param facets the facetsId
201     */

202    public void setFacetsId(String JavaDoc facetsId)
203    {
204       this.facetsId = facetsId;
205    }
206
207
208    /** the facets component Id */
209    private String JavaDoc facetsId;
210
211    /** the expandedActionListener */
212    private String JavaDoc expandedActionListener;
213    
214    /** the expanded flag */
215    private String JavaDoc expanded;
216
217    /** the border */
218    private String JavaDoc border;
219
220    /** the progressive */
221    private String JavaDoc progressive;
222
223    /** the label */
224    private String JavaDoc label;
225
226    /** the bgcolor */
227    private String JavaDoc bgcolor;
228
229    /** the title border style */
230    private String JavaDoc titleBorder;
231    
232    /** the title bgcolor */
233    private String JavaDoc titleBgcolor;
234 }
235
Popular Tags