View Javadoc

1   /*
2    * $Id: SortTools.java,v 1.1 2007/04/20 13:43:05 oeuillot Exp $
3    */
4   package org.rcfaces.core.internal.tools;
5   
6   import javax.faces.component.UIComponent;
7   import javax.faces.context.FacesContext;
8   
9   import org.rcfaces.core.internal.capability.IComponentEngine;
10  import org.rcfaces.core.internal.component.Properties;
11  
12  /**
13   * 
14   * @author Olivier Oeuillot (latest modification by $Author: oeuillot $)
15   * @version $Revision: 1.1 $ $Date: 2007/04/20 13:43:05 $
16   */
17  public class SortTools {
18  
19      private static final UIComponent[] COMPONENT_EMPTY_ARRAY = new UIComponent[0];
20  
21      public static UIComponent[] getSortedChildren(FacesContext facesContext,
22              UIComponent component, IComponentEngine engine, Class classOfChild) {
23  
24          return ComponentTools.listChildren(facesContext, component, engine,
25                  classOfChild, Properties.SORTED_CHILDREN);
26      }
27  
28      public static UIComponent getFirstSortedChild(FacesContext facesContext,
29              UIComponent component, IComponentEngine engine, Class classOfChild) {
30          UIComponent children[] = getSortedChildren(facesContext, component,
31                  engine, classOfChild);
32          if (children == null || children.length < 1) {
33              return null;
34          }
35  
36          return children[0];
37      }
38  
39      public static void setSortedChildren(FacesContext facesContext,
40              UIComponent component, IComponentEngine engine, Class classOfChild,
41              UIComponent[] children) {
42  
43          ComponentTools.setChildren(component, engine, classOfChild, children,
44                  Properties.SORTED_CHILDREN);
45  
46      }
47  }