View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package javax.faces.webapp;
21  
22  import java.util.logging.Logger;
23  
24  import javax.el.ELContext;
25  import javax.faces.component.UIComponent;
26  import javax.faces.context.FacesContext;
27  import javax.servlet.jsp.tagext.JspTag;
28  
29  /**
30   * @author Dennis Byrne
31   * @since 1.2
32   */
33  
34  public abstract class UIComponentTagBase extends Object implements JspTag
35  {
36  
37      protected static Logger log = Logger.getLogger("javax.faces.webapp");
38      
39      /**
40       * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#addChild(javax.faces.component.UIComponent)
41       * @param child
42       */
43  
44      protected abstract void addChild(UIComponent child);
45  
46      /**
47       * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#addFacet(java.lang.String)
48       * @param name
49       */
50  
51      protected abstract void addFacet(String name);
52  
53      /**
54       * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#getComponentInstance()
55       * @return
56       */
57  
58      public abstract UIComponent getComponentInstance();
59  
60      /**
61       * Specify the "component type name" used together with the component's
62       * family and the Application object to create a UIComponent instance for
63       * this tag. This method is called by other methods in this class, and is
64       * intended to be overridden in subclasses to specify the actual component
65       * type to be created.
66       *
67       * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#getComponentType()
68       * @return a registered component type name, never null.
69       */
70  
71      public abstract String getComponentType();
72  
73      /**
74       * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#getCreated()
75       * @return
76       */
77  
78      public abstract boolean getCreated();
79  
80      /**
81       * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#getELContext()
82       * @return
83       */
84  
85      protected ELContext getELContext()
86      {
87  
88          FacesContext ctx = getFacesContext();
89  
90          if (ctx == null)
91          {
92              throw new NullPointerException("FacesContext ctx");
93          }
94  
95          return getFacesContext().getELContext();
96      }
97  
98      /**
99       * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#getFacesContext()
100      * @return
101      */
102 
103     protected abstract FacesContext getFacesContext();
104 
105     /**
106      * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#getIndexOfNextChildTag()
107      * @return
108      */
109 
110     protected abstract int getIndexOfNextChildTag();
111 
112     /**
113      * Specify the "renderer type name" used together with the current
114      * renderKit to get a Renderer instance for the corresponding UIComponent.
115      * <p>
116      * A JSP tag can return null here to use the default renderer type string.
117      * If non-null is returned, then the UIComponent's setRendererType method
118      * will be called passing this value, and this will later affect the
119      * type of renderer object returned by UIComponent.getRenderer().
120      * 
121      * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#getRendererType()
122      * @return
123      */
124     public abstract String getRendererType();
125 
126     /**
127      * @see http://java.sun.com/javaee/5/docs/api/javax/faces/webapp/UIComponentTagBase.html#setId(java.lang.String)
128      * @param id
129      */
130 
131     public abstract void setId(String id);
132 }