View Javadoc

1   /*
2    * Copyright 2004 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.myfaces.renderkit.html;
17  
18  import java.util.List;
19  
20  import javax.faces.application.ViewHandler;
21  import javax.faces.component.UIComponent;
22  import javax.faces.context.FacesContext;
23  import javax.faces.render.Renderer;
24  
25  import org.apache.commons.logging.Log;
26  import org.apache.commons.logging.LogFactory;
27  
28  
29  /***
30   * @author Manfred Geiler (latest modification by $Author: matzew $)
31   * @version $Revision: 376993 $ $Date: 2006-02-11 15:34:59 +0000 (Sat, 11 Feb 2006) $
32   */
33  public abstract class HtmlRenderer
34          extends Renderer
35  {
36      private static final Log log = LogFactory.getLog(HtmlRenderer.class);
37  
38      /***
39       * Return the list of children of the specified component.
40       * <p>
41       * This default implementation simply returns component.getChildren().
42       * However this method should always be used in order to allow
43       * renderer subclasses to override it and provide filtered or
44       * reordered views of the component children to rendering
45       * methods defined in their ancestor classes.
46       * <p>
47       * Any method that overrides this to "hide" child components
48       * should also override the getChildCount method.
49       * 
50       * @return a list of UIComponent objects.
51       */
52      public List getChildren(UIComponent component) 
53      {
54          return component.getChildren();
55      }
56  
57      /***
58       * Return the number of children of the specified component.
59       * <p>
60       * See {@link #getChildren(UIComponent)} for more information.
61       */
62      public int getChildCount(UIComponent component) 
63      {
64          return component.getChildCount();
65      }
66      
67      /***
68       * @param facesContext
69       * @return String A String representing the action URL
70       */
71      protected String getActionUrl(FacesContext facesContext)
72      {
73          ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
74          String viewId = facesContext.getViewRoot().getViewId();
75          return viewHandler.getActionURL(facesContext, viewId);
76      }
77  }