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.util.ArrayList;
25  import java.util.List;
26  import javax.faces.component.NamingContainer;
27  import javax.faces.component.UIComponent;
28  import javax.faces.component.visit.VisitCallback;
29  import javax.faces.component.visit.VisitContext;
30  import javax.faces.context.FacesContext;
31  import javax.faces.event.PhaseId;
32  import org.apache.myfaces.trinidad.bean.FacesBean;
33  import org.apache.myfaces.trinidad.bean.PropertyKey;
34  import org.apache.myfaces.trinidad.util.ComponentUtils;
35  
36  /**
37   *
38   * A navigationPath component is used in hierarchical
39   *           site layouts to indicate the path back to the root page of the
40   *           hierarchy with links.
41   *
42   * <h4>Events:</h4>
43   * <table border="1" width="100%" cellpadding="3" summary="">
44   * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
45   * <th align="left">Type</th>
46   * <th align="left">Phases</th>
47   * <th align="left">Description</th>
48   * </tr>
49   * <tr class="TableRowColor">
50   * <td valign="top"><code>org.apache.myfaces.trinidad.event.AttributeChangeEvent</code></td>
51   * <td valign="top" nowrap>Invoke<br>Application<br>Apply<br>Request<br>Values</td>
52   * <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>
53   * </tr>
54   * </table>
55   */
56  public class UIXNavigationPath extends UIXNavigationHierarchy
57                                 implements NamingContainer
58  {
59    static public final FacesBean.Type TYPE = new FacesBean.Type(
60      UIXNavigationHierarchy.TYPE);
61    static public final PropertyKey VALUE_KEY =
62      TYPE.registerKey("value", Object.class, null, 0, PropertyKey.Mutable.SOMETIMES);
63    static public final PropertyKey VAR_STATUS_KEY =
64      TYPE.registerKey("varStatus", String.class, PropertyKey.CAP_NOT_BOUND);
65    static public final String NODE_STAMP_FACET = "nodeStamp";
66  
67    static public final String COMPONENT_FAMILY =
68      "org.apache.myfaces.trinidad.NavigationPath";
69    static public final String COMPONENT_TYPE =
70      "org.apache.myfaces.trinidad.NavigationPath";
71  
72    /**
73     * Construct an instance of the UIXNavigationPath.
74     */
75    public UIXNavigationPath()
76    {
77      super("org.apache.myfaces.trinidad.Path");
78    }
79      
80    @Override
81    protected void processFacetsAndChildren(
82      FacesContext context,
83      PhaseId phaseId)
84    {
85      Object oldPath = getRowKey();
86      
87      Object focusPath = getFocusRowKey();
88      
89      if (focusPath != null )
90      {
91        List<Object> paths = 
92          new ArrayList<Object>(getAllAncestorContainerRowKeys(focusPath));
93        
94        paths.add(focusPath);
95        int focusPathSize = paths.size();
96        UIComponent nodeStamp = getFacet("nodeStamp");
97        
98        if (nodeStamp != null)
99        {
100         for (int i = 0; i < focusPathSize; i++)
101         {
102           setRowKey(paths.get(i));
103           processComponent(context, nodeStamp, phaseId);
104         }
105       }
106     }
107     
108     setRowKey(oldPath);
109     
110     // process the children
111     TableUtils.__processChildren(context, this, phaseId);
112   }  
113 
114   @Override
115   protected boolean visitChildren(
116     VisitContext  visitContext,
117     VisitCallback callback)
118   {
119     if (ComponentUtils.isSkipIterationVisit(visitContext))
120     {
121       return visitChildrenWithoutIterating(visitContext, callback);
122     }
123     else
124     {
125       return _visitChildrenIterating(visitContext, callback);
126     }
127   }
128 
129   private boolean _visitChildrenIterating(
130     VisitContext  visitContext,
131     VisitCallback callback)
132   {
133     boolean done = visitData(visitContext, callback);
134     
135     if (!done)
136     {
137       // process the children
138       int childCount = getChildCount();
139       if (childCount > 0)
140       {
141         for (UIComponent child : getChildren())
142         {
143           done = UIXComponent.visitTree(visitContext, child, callback);
144           
145           if (done)
146             break;
147         }
148       }          
149     }
150     
151     return done;
152   }
153   
154   @Override
155   protected boolean visitData(
156     VisitContext  visitContext,
157     VisitCallback callback)
158   {
159     Object focusPath = getFocusRowKey();
160     Object oldRowKey = null;
161     
162     boolean done = false;
163     
164     // start from the focused area
165     if (focusPath != null)
166     {
167       List<UIComponent> stamps = getStamps();
168       
169       if (!stamps.isEmpty())
170       {
171         List<Object> paths =  new ArrayList<Object>(getAllAncestorContainerRowKeys(focusPath));
172         paths.add(focusPath);
173         
174         int focusPathSize = paths.size();
175         
176         try
177         {
178           for (int i = 0; i < focusPathSize && !done; i++)
179           {
180             setRowKey(paths.get(i));
181             
182             for (UIComponent stamp : stamps)
183             {
184               done = UIXComponent.visitTree(visitContext, stamp, callback);
185               
186               if (done)
187                 break;
188             }
189           }
190         }
191         finally
192         {
193           setRowKey(oldRowKey);
194         }
195       }
196     }
197     
198     return done;
199   } 
200 
201   /**
202    * the component to use to stamp each element in the
203    *               navigation. A CommandNavigationItem is expected.
204    */
205   final public UIComponent getNodeStamp()
206   {
207     return getFacet(NODE_STAMP_FACET);
208   }
209 
210   /**
211    * the component to use to stamp each element in the
212    *               navigation. A CommandNavigationItem is expected.
213    */
214   @SuppressWarnings("unchecked")
215   final public void setNodeStamp(UIComponent nodeStampFacet)
216   {
217     getFacets().put(NODE_STAMP_FACET, nodeStampFacet);
218   }
219 
220   /**
221    * Gets the hierarchy of navigation data - must be of type 
222    *             org.apache.myfaces.trinidad.model.MenuModel
223    *
224    * @return  the new value value
225    */
226   final public Object getValue()
227   {
228     return getProperty(VALUE_KEY);
229   }
230 
231   /**
232    * Sets the hierarchy of navigation data - must be of type 
233    *             org.apache.myfaces.trinidad.model.MenuModel
234    * 
235    * @param value  the new value value
236    */
237   final public void setValue(Object value)
238   {
239     setProperty(VALUE_KEY, (value));
240   }
241 
242   /**
243    * Gets <html>
244    *  Name of the EL variable used to reference the varStatus information.
245    *           Once this component has completed rendering, this variable is
246    *           removed (or reverted back to its previous value).
247    *           The VarStatus provides contextual information about the state of the
248    *           component to EL expressions. For components that iterate, varStatus
249    *           also provides loop counter information.  Please see the this 
250    *           component's documentation for the specific properties on the varStatus.
251    *           The common properties on varStatus include:<ul><li>"model" - returns the CollectionModel for this component</li><li>"index" - returns the zero based row index</li></ul></html>
252    *
253    * @return  the new varStatus value
254    */
255   final public String getVarStatus()
256   {
257     return ComponentUtils.resolveString(getProperty(VAR_STATUS_KEY));
258   }
259 
260   /**
261    * Sets <html>
262    *  Name of the EL variable used to reference the varStatus information.
263    *           Once this component has completed rendering, this variable is
264    *           removed (or reverted back to its previous value).
265    *           The VarStatus provides contextual information about the state of the
266    *           component to EL expressions. For components that iterate, varStatus
267    *           also provides loop counter information.  Please see the this 
268    *           component's documentation for the specific properties on the varStatus.
269    *           The common properties on varStatus include:<ul><li>"model" - returns the CollectionModel for this component</li><li>"index" - returns the zero based row index</li></ul></html>
270    * 
271    * @param varStatus  the new varStatus value
272    */
273   final public void setVarStatus(String varStatus)
274   {
275     setProperty(VAR_STATUS_KEY, (varStatus));
276   }
277 
278   @Override
279   public String getFamily()
280   {
281     return COMPONENT_FAMILY;
282   }
283 
284   @Override
285   protected FacesBean.Type getBeanType()
286   {
287     return TYPE;
288   }
289 
290   /**
291    * Construct an instance of the UIXNavigationPath.
292    */
293   protected UIXNavigationPath(
294     String rendererType
295     )
296   {
297     super(rendererType);
298   }
299 
300   static
301   {
302     TYPE.lockAndRegister("org.apache.myfaces.trinidad.NavigationPath","org.apache.myfaces.trinidad.Path");
303   }
304 }