View Javadoc

1   // WARNING: This file was automatically generated. Do not edit it directly,
2   //          or you will lose your changes.
3   
4   /*
5    * Licensed to the Apache Software Foundation (ASF) under one
6    * or more contributor license agreements.  See the NOTICE file
7    * distributed with this work for additional information
8    * regarding copyright ownership.  The ASF licenses this file
9    * to you under the Apache License, Version 2.0 (the
10   * "License"); you may not use this file except in compliance
11   * with the License.  You may obtain a copy of the License at
12   *
13   *   http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing,
16   * software distributed under the License is distributed on an
17   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18   * KIND, either express or implied.  See the License for the
19   * specific language governing permissions and limitations
20   * under the License.
21  */
22  package org.apache.myfaces.trinidad.component;
23  
24  import java.io.IOException;
25  import java.util.List;
26  import javax.faces.component.UIComponent;
27  import javax.faces.context.FacesContext;
28  import org.apache.myfaces.trinidad.bean.FacesBean;
29  import org.apache.myfaces.trinidad.bean.PropertyKey;
30  import org.apache.myfaces.trinidad.util.ComponentUtils;
31  
32  /**
33   *
34   * The group component is an invisible control that aggregates semantically-related children; the group itself has no associated client representation (visual or API).
35   * Some parent components may have special representation for groups like adding separators around the group but this is a special case and is not always rendered this way.
36   * In most cases, only the children of the group will be rendered directly to the page.
37   * There will be no layout applied to the children so the natural layout behavior of the underlying HTML elements will apply.
38   * If you require a more predictable layout, you should use a layout component such as panelGroupLayout.
39   *
40   * <h4>Events:</h4>
41   * <table border="1" width="100%" cellpadding="3" summary="">
42   * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
43   * <th align="left">Type</th>
44   * <th align="left">Phases</th>
45   * <th align="left">Description</th>
46   * </tr>
47   * <tr class="TableRowColor">
48   * <td valign="top"><code>org.apache.myfaces.trinidad.event.AttributeChangeEvent</code></td>
49   * <td valign="top" nowrap>Invoke<br>Application<br>Apply<br>Request<br>Values</td>
50   * <td valign="top">Event delivered to describe an attribute change.  Attribute change events are not delivered for any programmatic change to a property.  They are only delivered when a renderer changes a property without the application's specific request.  An example of an attribute change event might include the width of a column that supported client-side resizing.</td>
51   * </tr>
52   * </table>
53   */
54  public class UIXGroup extends UIXComponentBase
55                        implements FlattenedComponent
56  {
57    static public final String START_BOUNDARY_SHOW = "show";
58    static public final String START_BOUNDARY_HIDE = "hide";
59    static public final String START_BOUNDARY_DONT_CARE = "dontCare";
60    static public final String END_BOUNDARY_SHOW = "show";
61    static public final String END_BOUNDARY_HIDE = "hide";
62    static public final String END_BOUNDARY_DONT_CARE = "dontCare";
63    static public final FacesBean.Type TYPE = new FacesBean.Type(
64      UIXComponentBase.TYPE);
65    static public final PropertyKey START_BOUNDARY_KEY =
66      TYPE.registerKey("startBoundary", String.class, "dontCare");
67    static public final PropertyKey END_BOUNDARY_KEY =
68      TYPE.registerKey("endBoundary", String.class, "dontCare");
69    static public final PropertyKey TITLE_KEY =
70      TYPE.registerKey("title", String.class);
71  
72    static public final String COMPONENT_FAMILY =
73      "org.apache.myfaces.trinidad.Group";
74    static public final String COMPONENT_TYPE =
75      "org.apache.myfaces.trinidad.Group";
76  
77    /**
78     * Construct an instance of the UIXGroup.
79     */
80    public UIXGroup()
81    {
82      super(null);
83    }
84      /**
85     * Overridden to return true.
86     * @return true because the children are rendered by this component
87     */
88    @Override
89    public boolean getRendersChildren()
90    {
91      return true;
92    }
93  
94    /**
95     * Sets up the grouping context and processes all of the
96     * UIXGroup's children
97     */
98    public <S> boolean processFlattenedChildren(
99      FacesContext context,
100     ComponentProcessingContext cpContext,
101     ComponentProcessor<S> childProcessor,
102     S callBackContext
103     ) throws IOException
104   {
105     cpContext.pushGroup();
106 
107     try
108     {
109       setupFlattenedContext(context, cpContext);
110       try
111       {
112         setupFlattenedChildrenContext(context, cpContext);
113 
114         try
115         {
116           // bump up the group depth and render all of the children
117           return UIXComponent.processFlattenedChildren(context,
118                                                        cpContext,
119                                                        childProcessor,
120                                                        this.getChildren(),
121                                                        callBackContext);
122         }
123         finally
124         {
125           tearDownFlattenedChildrenContext(context, cpContext);
126         }
127       }
128       finally
129       {
130         tearDownFlattenedContext(context, cpContext);
131       }
132     }
133     finally
134     {
135       cpContext.popGroup();
136     }
137   }
138 
139   /**
140    * Returns <code>true</code> if this FlattenedComponent is currently flattening its children
141    * @param context FacesContext
142    * @return <code>true</code> if this FlattenedComponent is currently flattening its children
143    */
144   public boolean isFlatteningChildren(FacesContext context)
145   {
146     return true;
147   }
148 
149   /**
150    * Renders the children in their raw form.
151    * There is no Renderer for this component because it has no
152    * visual representation or any sort of layout for its children.
153    * @param context the FacesContext
154    * @throws IOException if there is an error encoding the children
155    */
156   @Override
157   public void encodeChildren(FacesContext context) throws IOException
158   {
159     if (context == null)
160       throw new NullPointerException();
161 
162     if (!isRendered())
163       return;
164 
165     if (getChildCount() > 0)
166     {
167       for(UIComponent child : (List<UIComponent>)getChildren())
168       {
169         child.encodeAll(context);
170       }
171     }
172   }
173 
174   /**
175    * Gets <html>
176    *           indicates if a visual group start boundary is desired. The default value of 'dontCare' 
177    *           indicates no preference. A value of 'show' indicates a preference to show a start boundary.
178    *           A value of 'hide' indicates a preference to not show a start boundary. Regardless of the 
179    *           start boundary value, whether a visual boundary will be displayed is up to the group's 
180    *           parent component.
181    *         </html>
182    *
183    * @return  the new startBoundary value
184    */
185   final public String getStartBoundary()
186   {
187     return ComponentUtils.resolveString(getProperty(START_BOUNDARY_KEY), "dontCare");
188   }
189 
190   /**
191    * Sets <html>
192    *           indicates if a visual group start boundary is desired. The default value of 'dontCare' 
193    *           indicates no preference. A value of 'show' indicates a preference to show a start boundary.
194    *           A value of 'hide' indicates a preference to not show a start boundary. Regardless of the 
195    *           start boundary value, whether a visual boundary will be displayed is up to the group's 
196    *           parent component.
197    *         </html>
198    * 
199    * @param startBoundary  the new startBoundary value
200    */
201   final public void setStartBoundary(String startBoundary)
202   {
203     setProperty(START_BOUNDARY_KEY, (startBoundary));
204   }
205 
206   /**
207    * Gets <html>
208    *           indicates if a visual group end boundary is desired. The default value of 'dontCare' 
209    *           indicates no preference. A value of 'show' indicates a preference to show an end boundary.
210    *           A value of 'hide' indicates a preference to not show an end boundary. Regardless of the 
211    *           end boundary value, whether a visual boundary will be displayed is up to the group's 
212    *           parent component.
213    *         </html>
214    *
215    * @return  the new endBoundary value
216    */
217   final public String getEndBoundary()
218   {
219     return ComponentUtils.resolveString(getProperty(END_BOUNDARY_KEY), "dontCare");
220   }
221 
222   /**
223    * Sets <html>
224    *           indicates if a visual group end boundary is desired. The default value of 'dontCare' 
225    *           indicates no preference. A value of 'show' indicates a preference to show an end boundary.
226    *           A value of 'hide' indicates a preference to not show an end boundary. Regardless of the 
227    *           end boundary value, whether a visual boundary will be displayed is up to the group's 
228    *           parent component.
229    *         </html>
230    * 
231    * @param endBoundary  the new endBoundary value
232    */
233   final public void setEndBoundary(String endBoundary)
234   {
235     setProperty(END_BOUNDARY_KEY, (endBoundary));
236   }
237 
238   /**
239    * Gets <html>
240    *           a title value for the group. Whether anything is done with this title value is up to the 
241    *           group's parent component.
242    *         </html>
243    *
244    * @return  the new title value
245    */
246   final public String getTitle()
247   {
248     return ComponentUtils.resolveString(getProperty(TITLE_KEY));
249   }
250 
251   /**
252    * Sets <html>
253    *           a title value for the group. Whether anything is done with this title value is up to the 
254    *           group's parent component.
255    *         </html>
256    * 
257    * @param title  the new title value
258    */
259   final public void setTitle(String title)
260   {
261     setProperty(TITLE_KEY, (title));
262   }
263 
264   @Override
265   public String getFamily()
266   {
267     return COMPONENT_FAMILY;
268   }
269 
270   @Override
271   protected FacesBean.Type getBeanType()
272   {
273     return TYPE;
274   }
275 
276   /**
277    * Construct an instance of the UIXGroup.
278    */
279   protected UIXGroup(
280     String rendererType
281     )
282   {
283     super(rendererType);
284   }
285 
286   static
287   {
288     TYPE.lock();
289   }
290 }