UIComponentClassicTagBase (Java EE 5)

Java EE API


javax.faces.webapp Class UIComponentClassicTagBase

java.lang.Object
  extended by javax.faces.webapp.UIComponentTagBase
      extended by javax.faces.webapp.UIComponentClassicTagBase
All Implemented Interfaces:
BodyTag, IterationTag, JspIdConsumer, JspTag, Tag
Direct Known Subclasses:
UIComponentELTag, UIComponentTag

public abstract class UIComponentClassicTagBase
extends UIComponentTagBase
implements JspIdConsumer, BodyTag

Implements: javax.servlet.jsp.tagext.JspIdConsumer, BodyTag

UIComponentTagBase 是所有满足以下条件的 JSP 标记的基类:这些标记使用 "classic" JSP 标记接口,而该接口对应于视图中的 javax.faces.component.UIComponent 实例。在 Faces 1.2 中,所有组件标记都是 BodyTag 实例,以允许页面构建组件树,但是不呈现它。仅当完全构建组件树之后才会发生呈现。

UIComponentTag 扩展了 UIComponentClassicTagBase,添加了对符合 Faces 1.1 EL 的属性的支持。

UIComponentELTag 扩展了 UIComponentClassicTagBase 类,添加了对符合 EL API 的属性的支持。

默认实现允许根据页面作者的要求,在同一页面上适当混杂模板文本、非 Faces JSP 标记输出和 Faces 组件标记输出。

以下示例中的 CASE 标记将在此类的方法描述中引用。

  • CASE 1 描述作为组件标记的子标记出现的模板文本和/或非组件自定义标记输出,但是位置在该组件标记的第一个子组件标记出现之前。

  • CASE 2 描述在两个兄弟组件标记之间出现的模板文本和/或非组件自定义标记输出。

  • CASE 3 描述作为页面上任何位置的 <f:verbatim> 标记的子内容出现的模板文本和/或非组件自定义标记输出。

  • CASE 4 描述在最后一个子组件标记及其封装父组件标记的结束标记之间出现的模板文本和/或非组件自定义标记输出。

<h:panelGrid style="color:red" border="4" columns="2">
CASE 1
<h:outputText value="component 1"/>
CASE 2
<h:outputText value="component 2"/>
<f:verbatim>CASE 3</f:verbatim>
<c:out value="${pageScope.CASE4}" />
</h:panelGrid>

 

上述 faces 组件标记的排列必须得到与以下呈现方式相同的标记(假设对 ${pageScope.CASE4} 求值得到 "CASE 4",不带引号)。

<table border="4" style="color:red">

<tbody>

<tr><td>CASE 1</td></tr> <tr><td>component 1</td></tr> 

<tr><td>CASE 2</td> <tr><td>component 2</td></tr> 

<tr><td>CASE 3</td> <td>CASE 4</td></tr>

</tbody>

</table>

 
英文文档:

UIComponentTagBase is the base class for all JSP tags that use the "classic" JSP tag interface that correspond to a UIComponent instance in the view. In Faces 1.2, all component tags are BodyTag instances to allow for the execution of the page to build the component tree, but not render it. Rendering happens only after the component tree is completely built.

UIComponentTag extends UIComponentClassicTagBase to add support for properties that conform to the Faces 1.1 EL.

UIComponentELTag extends UIComponentClassicTagBase class to add support for properties that conform to the EL API.

The default implementation allows the proper interweaving of template text, non-Faces JSP tag output, and Faces component tag output in the same page, as expected by the page author.

The CASE markers in the following example will be cited in the method descriptions of this class.

  • CASE 1 describes template text and/or non-component custom tag output occurring as the child of a component tag, but before the first component tag child of that component tag.

  • CASE 2 describes template text and/or non-component custom tag output occurring between two sibling component tags.

  • CASE 3 describes template text and/or non-component custom tag output occurring as the child content of an <f:verbatim> tag at any point in the page.

  • CASE 4 describes template text and/or non-component custom tag output occurring between the last child component tag and its enclosing parent component tag's end tag.

    <h:panelGrid style="color:red" border="4" columns="2">
      CASE 1
      <h:outputText value="component 1"/>
      CASE 2
      <h:outputText value="component 2"/>
      <f:verbatim>CASE 3</f:verbatim>
      <c:out value="${pageScope.CASE4}" />
    </h:panelGrid>

 

The preceding arrangement of faces component tags, must yield markup that will render identically to the following (assuming that ${pageScope.CASE4} evaluates to "CASE 4" without the quotes).

<table border="4" style="color:red">

  <tbody>

    <tr><td>CASE 1</td></tr> <tr><td>component 1</td></tr> 

    <tr><td>CASE 2</td> <tr><td>component 2</td></tr> 

    <tr><td>CASE 3</td> <td>CASE 4</td></tr>

  </tbody>

</table>

 


Field Summary
protected  BodyContent
protected  PageContext
protected static String
 
Fields inherited from class javax.faces.webapp.UIComponentTagBase
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
 
Constructor Summary
 
Method Summary
protected  void
protected  void
protected  void
protected  void
protected abstract  UIComponent
protected  UIOutput
protected  UIComponent
 int
 int
 void
 int
protected  void
protected  void
protected  void
protected  UIComponent
 BodyContent
 UIComponent
 boolean
protected  List<String>
protected  int
protected  int
protected  int
protected  FacesContext
protected  String
protected  String
protected  String
protected  int
 String
 Tag
static UIComponentClassicTagBase
 JspWriter
protected abstract  boolean
 void
 void
 void
 void
 void
 void
protected abstract  void
protected  void
 
Methods inherited from class javax.faces.webapp.UIComponentTagBase
 
Methods inherited from class java.lang.Object
 

Field Detail

英文文档:

UNIQUE_ID_PREFIX

protected static final String UNIQUE_ID_PREFIX
Used as the prefix for ids. This is necessary to avoid uniqueness conflicts with the transient verbatim components.

See Also:
Constant Field Values


英文文档:

bodyContent

protected BodyContent bodyContent

The bodyContent for this tag handler.


英文文档:

pageContext

protected PageContext pageContext

The JSP PageContext for the page we are embedded in.

Constructor Detail

public UIComponentClassicTagBase()
英文文档:

UIComponentClassicTagBase

public UIComponentClassicTagBase()
Method Detail

protected int getDoStartValue() throws JspException

返回调用 doStart() 方法时应该从该方法返回的标志值。子类可重写此方法,以返回相应的值。

ThrowsJspException: 导致 doStart() 抛出异常
英文文档:

getDoStartValue

protected int getDoStartValue()
                       throws JspException

Return the flag value that should be returned from the doStart() method when it is called. Subclasses may override this method to return the appropriate value.

Throws:
JspException - to cause doStart() to throw an exception

protected int getDoEndValue() throws JspException

返回调用 doEnd() 方法时应该从该方法返回的标志值。子类可重写此方法,以返回相应的值。

ThrowsJspException: 导致 doEnd() 抛出异常
英文文档:

getDoEndValue

protected int getDoEndValue()
                     throws JspException

Return the flag value that should be returned from the doEnd() method when it is called. Subclasses may override this method to return the appropriate value.

Throws:
JspException - to cause doEnd() to throw an exception

protected void encodeBegin() throws java.io.IOException

委托给相应 UIComponentencodeBegin() 方法。此方法从 doStartTag() 调用。通常,代理是无条件发生的,但是此方法有所不同,高级标记可以有条件地执行此调用。

Throwsjava.io.IOException: 如果发生输入/输出错误
deprecated 执行 JSP 页面期间不执行任何编码。编码推迟到页面完成执行时,以在发生编码前构建整个树。

英文文档:

encodeBegin

protected void encodeBegin()
                    throws IOException
Deprecated. No encoding is done during JSP page execution. Encoding is deferred until the page has completed executing to allow the entire tree to be built before any encoding occurs.

Delegate to the encodeBegin() method of our corresponding UIComponent. This method is called from doStartTag(). Normally, delegation occurs unconditionally; however, this method is abstracted out so that advanced tags can conditionally perform this call.

Throws:
IOException - if an input/output error occurs

protected void encodeChildren() throws java.io.IOException

委托给相应 UIComponentencodeChildren() 方法。此方法从 doStartTag() 调用。通常,代理是无条件发生的,但是此方法有所不同,高级标记可以有条件地执行此调用。

Throwsjava.io.IOException: 如果发生输入/输出错误
deprecated 执行 JSP 页面期间不执行任何编码。编码推迟到页面完成执行时,以在发生编码前构建整个树。

英文文档:

encodeChildren

protected void encodeChildren()
                       throws IOException
Deprecated. No encoding is done during JSP page execution. Encoding is deferred until the page has completed executing to allow the entire tree to be built before any encoding occurs.

Delegate to the encodeChildren() method of our corresponding UIComponent. This method is called from doStartTag(). Normally, delegation occurs unconditionally; however, this method is abstracted out so that advanced tags can conditionally perform this call.

Throws:
IOException - if an input/output error occurs

protected void encodeEnd() throws java.io.IOException

委托给相应 UIComponentencodeEnd() 方法。此方法从 doStartTag() 调用。通常,代理是无条件发生的,但是此方法有所不同,高级标记可以有条件地执行此调用。

Throwsjava.io.IOException: 如果发生输入/输出错误
deprecated 执行 JSP 页面期间不执行任何编码。编码推迟到页面完成执行时,以在发生编码前构建整个树。

英文文档:

encodeEnd

protected void encodeEnd()
                  throws IOException
Deprecated. No encoding is done during JSP page execution. Encoding is deferred until the page has completed executing to allow the entire tree to be built before any encoding occurs.

Delegate to the encodeEnd() method of our corresponding UIComponent. This method is called from doStartTag(). Normally, delegation occurs unconditionally; however, this method is abstracted out so that advanced tags can conditionally perform this call.

Throws:
IOException - if an input/output error occurs

public void setPageContext(PageContext pageContext)

设置包含此标记实例的页面的 PageContext

pageContext 封装的 PageContext
英文文档:

setPageContext

public void setPageContext(PageContext pageContext)

Set the PageContext of the page containing this tag instance.

Specified by:
setPageContext in interface Tag
Parameters:
pageContext - The enclosing PageContext

public Tag getParent()

返回作为此实例父组件的 Tag

英文文档:

getParent

public Tag getParent()

Return the Tag that is the parent of this instance.

Specified by:
getParent in interface Tag
Returns:
the current parent, or null if none.
See Also:
TagSupport.findAncestorWithClass(javax.servlet.jsp.tagext.Tag, java.lang.Class)

public void setParent(Tag parent)

设置作为此实例父组件的 Tag

parent 新的父 Tag
英文文档:

setParent

public void setParent(Tag parent)

Set the Tag that is the parent of this instance.

Specified by:
setParent in interface Tag
Parameters:
parent - The new parent Tag

protected void setupResponseWriter()

设置当前响应的 javax.faces.context.ResponseWriter(如果尚未设置)。

英文文档:

setupResponseWriter

protected void setupResponseWriter()

Set up the ResponseWriter for the current response, if this has not been done already.

@deprecated. ViewHandler.renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot) is now responsible for setting up the response writer. This method is now a no-op.


protected UIComponent findComponent(FacesContext context) throws JspException

从对应于此标记处理程序实例的组件树查找并返回 UIComponent。如果没有这样的 UIComponent,则创建一个,并将其添加为 UIComponent(它与最新封装的 UIComponentTag 关联)的子组件或 facet。定位或创建组件的过程如下:

  1. 如果之前找到了此组件,则返回它。
  2. 通过查找父 UIComponentTag 实例并请求其组件定位父组件。如果没有父 UIComponentTag 实例,则此标记表示根组件,因此应从当前的 Tree 中获取它并返回。
  3. 如果此 UIComponentTag 实例有 facetName 属性集,则向父 UIComponent 请求具有此名称的 facet。如果找不到,则创建一个,使用新组件作为参数调用 setProperties(),并以此名称注册它。返回找到或创建的 facet UIComponent
  4. 确定要分配给新组件的组件 ID,如下所示:如果此 UIComponentTag 有一个 id 属性集,则使用该值;否则,生成一个标识符,并保证每次处理页面时此 UIComponent 都有相同的标识符(即基于所有不带 id 属性集的 UIComponentTag 实例的位置)。
  5. 向父 UIComponent 请求带有此标识符的子组件。如果找不到,则创建一个,使用新组件作为参数调用 setProperties(),并将其注册为具有此标识符的子组件。返回找到或创建的子 UIComponent

创建组件时,过程如下:

  1. 通过调用 UIComponentTag#getComponentType 获取组件类型
  2. 如果组件有 binding 属性,则根据其创建一个表达式,并使用该表达式、FacesContext 和组件类型调用 Application#createComponent。使用关键字 "binding" 存储该表达式。
  3. 否则,调用 Application#createComponent,只有组件类型参数。
  4. 调用 setProperties()
  5. 将新组件添加为其父组件的子组件或 facet
英文文档:

findComponent

protected UIComponent findComponent(FacesContext context)
                             throws JspException

Find and return the UIComponent, from the component tree, that corresponds to this tag handler instance. If there is no such UIComponent, create one and add it as a child or facet of the UIComponent associated with our nearest enclosing UIComponentTag. The process for locating or creating the component is:

  1. If we have previously located this component, return it.
  2. Locate the parent component by looking for a parent UIComponentTag instance, and ask it for its component. If there is no parent UIComponentTag instance, this tag represents the root component, so get it from the current Tree and return it.
  3. If this UIComponentTag instance has the facetName attribute set, ask the parent UIComponent for a facet with this name. If not found, create one, call setProperties() with the new component as a parameter, and register it under this name. Return the found or created facet UIComponent.
  4. Determine the component id to be assigned to the new component, as follows: if this UIComponentTag has an id attribute set, use that value; otherwise, generate an identifier that is guaranteed to be the same for this UIComponent every time this page is processed (i.e. one based on the location of all UIComponentTag instances without an id attribute set).
  5. Ask the parent UIComponent for a child with this identifier. If not found, create one, call setProperties() with the new component as a parameter, and register it as a child with this identifier. Return the found or created child UIComponent.

When creating a component, the process is:

  1. Retrieve the component type by calling UIComponentTagBase.getComponentType()
  2. If the component has a binding attribute, create an expression from it, and call Application.createComponent(java.lang.String) with that expression, the FacesContext, and the component type. Store the expression using the key "binding".
  3. Otherwise, call Application.createComponent(java.lang.String) with only the component type.
  4. Call setProperties().
  5. Add the new component as a child or facet of its parent

Throws:
JspException

public static UIComponentClassicTagBase getParentUIComponentClassicTagBase(PageContext context)

查找并返回最新封装的 UIComponentClassicTagBase(如果有);否则返回 null

context 当前页面的 PageContext
英文文档:

getParentUIComponentClassicTagBase

public static UIComponentClassicTagBase getParentUIComponentClassicTagBase(PageContext context)

Locate and return the nearest enclosing UIComponentClassicTagBase if any; otherwise, return null.

Parameters:
context - PageContext for the current page

protected int getIndexOfNextChildTag()
英文文档:

getIndexOfNextChildTag

protected int getIndexOfNextChildTag()
Description copied from class: UIComponentTagBase

Return the index of the next child to be added as a child of this tag. The default implementation maintains a list of created components and returns the size of the list.

Specified by:
getIndexOfNextChildTag in class UIComponentTagBase

protected void addChild(UIComponent child)
英文文档:

addChild

protected void addChild(UIComponent child)
Description copied from class: UIComponentTagBase

Add the component identifier of the specified UIComponent to the list of component identifiers created or located by nested UIComponentTags processing this request.

Specified by:
addChild in class UIComponentTagBase
Parameters:
child - New child whose identifier should be added

protected void addFacet(String name)
英文文档:

addFacet

protected void addFacet(String name)
Description copied from class: UIComponentTagBase

Add the facet name of the specified facet to the list of facet names created or located by nested UIComponentTags processing this request.

Specified by:
addFacet in class UIComponentTagBase
Parameters:
name - Facet name to be added

protected UIComponent createVerbatimComponentFromBodyContent()

根据此标记实例的正文内容创建一个瞬态 UIOutput 组件;如果没有正文内容,正文内容为空白或正文内容为注释,则返回 null。

英文文档:

createVerbatimComponentFromBodyContent

protected UIComponent createVerbatimComponentFromBodyContent()

Create a transient UIOutput component from the body content, of this tag instance or return null if there is no body content, the body content is whitespace, or the body content is a comment.


protected UIOutput createVerbatimComponent()

使用 Application 实例创建带有以下特征的新组件。

componentTypejavax.faces.HtmlOutputText

transienttrue

escapefalse

idFacesContext.getViewRoot().createUniqueId()

英文文档:

createVerbatimComponent

protected UIOutput createVerbatimComponent()

Use the Application instance to create a new component with the following characteristics.

componentType is javax.faces.HtmlOutputText.

transient is true.

escape is false.

id is FacesContext.getViewRoot().createUniqueId()


protected void addVerbatimBeforeComponent(UIComponentClassicTagBase parentTag, UIComponent verbatim, UIComponent component)

在父组件的子组件列表的 component 中添加 verbatim,作为 component 的兄弟组件。verbatim 被添加到该列表中紧接 component 之前的位置。

英文文档:

addVerbatimBeforeComponent

protected void addVerbatimBeforeComponent(UIComponentClassicTagBase parentTag,
                                          UIComponent verbatim,
                                          UIComponent component)

Add verbatim as a sibling of component in component in the parent's child list. verbatim is added to the list at the position immediatly preceding component.


protected void addVerbatimAfterComponent(UIComponentClassicTagBase parentTag, UIComponent verbatim, UIComponent component)

在父组件的子组件列表的 component 中添加 verbatim,作为 component 的兄弟组件。verbatim 被添加到该列表中紧接 component 之后的位置。

英文文档:

addVerbatimAfterComponent

protected void addVerbatimAfterComponent(UIComponentClassicTagBase parentTag,
                                         UIComponent verbatim,
                                         UIComponent component)

Add verbatim as a sibling of component in component in the parent's child list. verbatim is added to the list at the position immediatly following component.


public int doStartTag() throws JspException

执行在对应于页面中此标记实例的视图中查找(或创建)UIComponent 实例所必需的任何处理,当且仅当创建了组件时,才根据页面作者的要求将其插入到树中合适的位置。其次,导致创建一个瞬态 UIOutput 组件,并将其置于树中标记的 UIComponent 实例之前。此 UIOutput 组件的值必须包含类描述中 CASE 1CASE 2 覆盖的所有内容。

默认实现足以满足大多数组件,要实现此次要需求,它可以调用 #getParentUIComponentClassicTagBase 并对结果调用 #createVerbatimComponentFromBodyContent。然后通过调用 #addVerbatimBeforeComponent 将返回的组件添加到树中标记实例的实际组件之前

在返回之前,组件被推送到此响应的组件堆栈中,以便 #getParentUIComponentClassicTagBase 方法能够正常工作。

要返回的标志值可以通过调用 getDoStartValue() 方法获取,如果它的标记子类不希望使用默认值,则可以重写该方法。

ThrowsJspException: 如果发生错误
英文文档:

doStartTag

public int doStartTag()
               throws JspException

Perform any processing necessary to find (or create) the UIComponent instance in the view corresponding to this tag instance in the page and, if and only if a component was created, insert it into the tree at the proper location as expected by the page author. Secondarily, cause a transient UIOutput component to be created and placed in the tree before the UIComponent instance for this tag. The value of this UIOutput component must include anything covered by CASE 1 or CASE 2 in the class description.

The default implementation, which is intended to be sufficient for most components, implements this secondary requirement by calling getParentUIComponentClassicTagBase(javax.servlet.jsp.PageContext), and calling createVerbatimComponentFromBodyContent() on the result. It then adds the returned component to the tree before the actual component for this tag instance instance by calling addVerbatimBeforeComponent(javax.faces.webapp.UIComponentClassicTagBase, javax.faces.component.UIComponent, javax.faces.component.UIComponent).

Before returning, the component is pushed onto the component stack for this response to enable the getParentUIComponentClassicTagBase(javax.servlet.jsp.PageContext) method to work properly.

The flag value to be returned is acquired by calling the getDoStartValue() method, which tag subclasses may override if they do not want the default value.

Specified by:
doStartTag in interface Tag
Returns:
EVAL_BODY_INCLUDE if the tag wants to process body, SKIP_BODY if it does not want to process it.
Throws:
JspException - if an error occurs
See Also:
BodyTag

public int doEndTag() throws JspException

执行任何必要的处理,以处理与类描述 CASE 3 类似的情况。

默认实现足以满足大多数组件,它可以对实例调用 #createVerbatimComponentFromBodyContent,并将其作为此标记组件的子组件添加到子组件列表的末尾。此外,还采取了以下内务处理步骤。

  • UIComponent 获取上一次处理此页面时 UIComponentTag 实例创建的子组件的组件 ID 集(如果有)。将其与处理此页面期间创建的子组件列表相比较,并移除旧列表中出现的所有子组件,但不删除新的子组件。将新列表保存为组件属性,以便它能作为组件状态的一部分保存。
  • UIComponent 获取上一次处理此页面时 UIComponentTag 实例创建的 facet 的 facet 名称集(如果有)。将其与处理此页面期间创建的 facet 列表相比较,并删除旧列表中出现的所有 facet,但不删除新的 facet。将新列表保存为组件属性,以便它能作为组件状态的一部分保存。
  • 释放对此组件的所有引用,并将其从此响应的组件堆栈中弹出;如果它是最外面的组件,则将此堆栈移除。

要返回的标志值可以通过调用 getDoEndValue() 方法获取,如果它的标记子类不希望使用默认值,则可以重写该方法。

ThrowsJspException: 如果发生错误
英文文档:

doEndTag

public int doEndTag()
             throws JspException

Perform any processing necessary to handle the content implications of CASE 3 in the class description.

The default implementation, which is intended to be sufficient for most components, calls createVerbatimComponentFromBodyContent() on this instance and adds it as a child of the component for this tag's component at the end of the child list. In addition, the following housekeeping steps are taken.

  • Retrieve from the UIComponent the set of component ids of child components created by UIComponentTag instances the last time this page was processed (if any). Compare it to the list of children created during this page processing pass, and remove all children present in the old list but not the new. Save the new list as a component attribute so that it gets saved as part of the component's state.
  • Retrieve from the UIComponent the set of facet names of facets created by UIComponentTag instances the last time this page was processed (if any). Compare it to the list of facets created during this page processing pass, and remove all facets present in the old list but not the new. Save the new list as a component attribute so that it gets saved as part of the component's state.
  • Release all references to the component, and pop it from the component stack for this response, removing the stack if this was the outermost component.

The flag value to be returned is acquired by calling the getDoEndValue() method, which tag subclasses may override if they do not want the default value.

Specified by:
doEndTag in interface Tag
Returns:
indication of whether to continue evaluating the JSP page.
Throws:
JspException - if an error occurs

public void release()

释放执行此标记处理程序期间分配的所有资源。

英文文档:

release

public void release()

Release any resources allocated during the execution of this tag handler.

Specified by:
release in interface Tag

protected int getDoAfterBodyValue() throws JspException

返回调用 doAfterBody() 方法时应该从该方法返回的标志值。子类可重写此方法,以返回相应的值。

英文文档:

getDoAfterBodyValue

protected int getDoAfterBodyValue()
                           throws JspException

Return the flag value that should be returned from the doAfterBody() method when it is called. Subclasses may override this method to return the appropriate value.

Throws:
JspException

public void setBodyContent(BodyContent bodyContent)

设置此标记处理程序的 bodyContent。此方法由 JSP 页面实现对象在 doInitiBody() 之前调用,每个操作调用最多调用一次。对于空标记或者 doStartTag() 方法返回 SKIP_BODYEVAL_BODY_INCLUDE 的非空标记,不调用此方法。

bodyContent 此标记的新 BodyContent
英文文档:

setBodyContent

public void setBodyContent(BodyContent bodyContent)

Set the bodyContent for this tag handler. This method is invoked by the JSP page implementation object at most once per action invocation, before doInitiBody(). This method will not be invoked for empty tags or for non-empty tags whose doStartTag() method returns SKIP_BODY or EVAL_BODY_INCLUDE.

Specified by:
setBodyContent in interface BodyTag
Parameters:
bodyContent - The new BodyContent for this tag
See Also:
BodyTag.doInitBody(), IterationTag.doAfterBody()

public JspWriter getPreviousOut()

BodyContent 获取 JspWriter

英文文档:

getPreviousOut

public JspWriter getPreviousOut()

Get the JspWriter from our BodyContent.


public BodyContent getBodyContent()
英文文档:

getBodyContent

public BodyContent getBodyContent()

public void doInitBody() throws JspException

准备对正文求值。此方法由 JSP 页面实现对象在 setBodyContent() 之后并在第一次对正文求值之前调用。对于空标记或者 doStartTag() 方法返回 SKIP_BODYEVAL_BODY_INCLUDE 的非空标记,不调用此方法。

ThrowsJspException: 如果遇到错误
英文文档:

doInitBody

public void doInitBody()
                throws JspException

Prepare for evaluation of the body. This method is invoked by the JSP page implementation object after setBodyContent() and before the first time the body is to be evaluated. This method will not be invoked for empty tags or for non-empty tags whose doStartTag() method returns SKIP_BODY or EVAL_BODY_INCLUDE.

Specified by:
doInitBody in interface BodyTag
Throws:
JspException - if an error is encountered
See Also:
IterationTag.doAfterBody()

public int doAfterBody() throws JspException

执行任何必要的处理,以处理与类描述 CASE 4 类似的情况。

返回 #getDoAfterBodyValue 的结果

ThrowsJspException: 如果遇到错误
英文文档:

doAfterBody

public int doAfterBody()
                throws JspException

Perform any processing necessary to handle the content implications of CASE 4 in the class description.

Return result from getDoAfterBodyValue()

Specified by:
doAfterBody in interface IterationTag
Returns:
whether additional evaluations of the body are desired
Throws:
JspException - if an error is encountered

public void setId(String id)

设置组件的组件标识符。如果参数以 UIViewRoot#UNIQUE_ID_PREFIX 开头,则抛出 IllegalArgumentException

id 新的组件标识符。它可以不以 UIViewRoot#UNIQUE_ID_PREFIX 开头。
ThrowsIllegalArgumentException: 如果参数为非 null 并且以 UIViewRoot#UNIQUE_ID_PREFIX 开头。
英文文档:

setId

public void setId(String id)

Set the component identifier for our component. If the argument begins with UIViewRoot.UNIQUE_ID_PREFIX throw an IllegalArgumentException

Specified by:
setId in class UIComponentTagBase
Parameters:
id - The new component identifier. This may not start with UIViewRoot.UNIQUE_ID_PREFIX.
Throws:
IllegalArgumentException - if the argument is non-null and starts with UIViewRoot.UNIQUE_ID_PREFIX.

protected String getId()

返回页面作者分配的 id 值。

英文文档:

getId

protected String getId()

Return the id value assigned by the page author.


protected String getFacesJspId()

如果在此标记的有效生存期中调用了此方法(在调用 #release 之前),则返回以前返回的值。否则,如果 #getJspId 返回非 null,则将 #UNIQUE_ID_PREFIX 添加到 jspId,并返回该结果。

英文文档:

getFacesJspId

protected String getFacesJspId()

If this method has been called before on this tag's useful lifetime (before release() was called), return the previously returned value. Otherwise, if getJspId() returns non-null, prepend UNIQUE_ID_PREFIX to the jspId and return the result.


protected java.util.List<E> getCreatedComponents()
返回处理当前请求期间嵌套的 UIComponentTag 创建或定位的 UIComponent ID List

英文文档:

getCreatedComponents

protected List<String> getCreatedComponents()
Returns the List of UIComponent ids created or located by nested UIComponentTags while processing the current request.


public void setJspId(String id)

JspIdConsumer 进行定义。此方法由容器在 #doStartTag 之前调用。保证参数在页面中是唯一的。

实现注意事项:此方法将检测我们所在的包含页面位置,并为特定“逻辑页面”中的每个包含页面分配一个唯一的 ID。这可以避免在组件没有显式 ID 的包含页面中出现重复 ID。

id 此标记的容器生成的 ID,保证在页面中是唯一的。
英文文档:

setJspId

public void setJspId(String id)

Defined on JspIdConsumer. This method is called by the container before doStartTag(). The argument is guaranteed to be unique within the page.

IMPLEMENTATION NOTE: This method will detect where we are in an include and assign a unique ID for each include in a particular 'logical page'. This allows us to avoid possible duplicate ID situations for included pages that have components without explicit IDs.

Specified by:
setJspId in interface JspIdConsumer
Parameters:
id - the container generated id for this tag, guaranteed to be unique within the page.

public String getJspId()
英文文档:

getJspId

public String getJspId()

abstract protected void setProperties(UIComponent component)

如果明确设置了此标记处理程序实例相应的属性,则重写指定组件的属性。仅当指定的 UIComponent 在执行此标记处理器实例期间实际创建时,才调用此方法,此调用将在向视图添加 UIComponent 之前发生。

希望支持其他设置属性的标记子类必须确保仍然调用了基类 setProperties() 方法。支持额外属性 foobar 的典型实现如下所示:

protected void setProperties(UIComponent component) {
super.setProperties(component);
if (foo != null) {
component.setAttribute("foo", foo);
   }
if (bar != null) {
component.setAttribute("bar", bar);
   }
 }
 

默认实现重写以下属性:

  • rendered - 为此标记处理程序实例指定了 rendered 属性的值时设置。
  • rendererType - getRendererType() 方法返回非 null 值时设置。
component 要重写属性的 UIComponent
英文文档:

setProperties

protected abstract void setProperties(UIComponent component)

Override properties and attributes of the specified component, if the corresponding properties of this tag handler instance were explicitly set. This method must be called ONLY if the specified UIComponent was in fact created during the execution of this tag handler instance, and this call will occur BEFORE the UIComponent is added to the view.

Tag subclasses that want to support additional set properties must ensure that the base class setProperties() method is still called. A typical implementation that supports extra properties foo and bar would look something like this:

 protected void setProperties(UIComponent component) {
   super.setProperties(component);
   if (foo != null) {
     component.setAttribute("foo", foo);
   }
   if (bar != null) {
     component.setAttribute("bar", bar);
   }
 }
 

The default implementation overrides the following properties:

  • rendered - Set if a value for the rendered property is specified for this tag handler instance.
  • rendererType - Set if the getRendererType() method returns a non-null value.

Parameters:
component - UIComponent whose properties are to be overridden

abstract protected UIComponent createComponent(FacesContext context, String newId) throws JspException

创建并返回新的类型(通过调用 getComponentType() 返回)子组件。如果此 UIComponentTag 拥有非 null 的 binding 属性,则使用为 binding 属性创建的表达式调用 Application#createComponent 实现,该表达式将被存储在组件中。否则,调用 Application#createComponent,只有组件类型参数。最后,初始化组件 ID 和其他属性。

context 当前请求的 FacesContext
newId 组件的 ID
英文文档:

createComponent

protected abstract UIComponent createComponent(FacesContext context,
                                               String newId)
                                        throws JspException

Create and return a new child component of the type returned by calling getComponentType(). If this UIComponentTag has a non-null binding attribute, this is done by call Application.createComponent(java.lang.String) with the expression created for the binding attribute, and the expression will be stored on the component. Otherwise, Application.createComponent(java.lang.String) is called with only the component type. Finally, initialize the components id and other properties.

Parameters:
context - FacesContext for the current request
newId - id of the component
Throws:
JspException

abstract protected boolean hasBinding()

如果此组件拥有非 null binding 属性,则返回 true。若要允许子类将 binding 属性公开为 Faces 1.1 风格的 EL 属性,以及将其公开为 EL API 属性,此方法是必需的。

英文文档:

hasBinding

protected abstract boolean hasBinding()

Return true if this component has a non-null binding attribute. This method is necessary to allow subclasses that expose the binding property as an Faces 1.1 style EL property as well as subclasses that expose it as an EL API property.


public UIComponent getComponentInstance()

返回关联此标记实例的 UIComponent 实例。此方法设计用于嵌套在标记中的标记,仅在对此标记实例执行 doStartTag()doEndTag() 期间返回有用的结果。

英文文档:

getComponentInstance

public UIComponent getComponentInstance()

Return the UIComponent instance that is associated with this tag instance. This method is designed to be used by tags nested within this tag, and only returns useful results between the execution of doStartTag() and doEndTag() on this tag instance.

Specified by:
getComponentInstance in class UIComponentTagBase

public boolean getCreated()

如果执行此标记期间动态创建了新的组件,则返回 true。此方法设计用于嵌套在标记中的标记,仅在对此标记实例执行 doStartTag()doEndTag() 期间返回有用的结果。

英文文档:

getCreated

public boolean getCreated()

Return true if we dynamically created a new component instance during execution of this tag. This method is designed to be used by tags nested within this tag, and only returns useful results between the execution of doStartTag() and doEndTag() on this tag instance.

Specified by:
getCreated in class UIComponentTagBase

protected FacesContext getFacesContext()
英文文档:

getFacesContext

protected FacesContext getFacesContext()
Description copied from class: UIComponentTagBase

Return the FacesContext instance for the current request. This value will be non-null only from the beginning of doStartTag() through the end of doEndTag() for each tag instance.

Specified by:
getFacesContext in class UIComponentTagBase

protected String getFacetName()

返回应该存储的 facet 名称(如果有),否则返回 null(表示为子组件)。

英文文档:

getFacetName

protected String getFacetName()

Return the facet name that we should be stored under, if any; otherwise, return null (indicating that we will be a child component).



Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!