|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.faces.webapp Class UIComponentClassicTagBase
java.lang.Object javax.faces.webapp.UIComponentTagBase 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
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 |
bodyContent
The bodyContent for this tag handler. |
protected PageContext |
pageContext
The JSP PageContext for the page we are embedded in. |
protected static String |
UNIQUE_ID_PREFIX
Used as the prefix for ids. |
Fields inherited from class javax.faces.webapp.UIComponentTagBase |
---|
log |
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag |
---|
EVAL_BODY_BUFFERED, EVAL_BODY_TAG |
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag |
---|
EVAL_BODY_AGAIN |
Fields inherited from interface javax.servlet.jsp.tagext.Tag |
---|
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE |
Constructor Summary | |
---|---|
UIComponentClassicTagBase()
|
Method Summary | |
---|---|
protected void |
addChild(UIComponent child)
Add the component identifier of the specified UIComponent
to the list of component identifiers created or located by nested
UIComponentTag s processing this request. |
protected void |
addFacet(String name)
Add the facet name of the specified facet to the list of facet names created or located by nested UIComponentTag s
processing this request. |
protected void |
addVerbatimAfterComponent(UIComponentClassicTagBase parentTag,
UIComponent verbatim,
UIComponent component)
Add verbatim as a sibling of component in component in the parent's child list. |
protected void |
addVerbatimBeforeComponent(UIComponentClassicTagBase parentTag,
UIComponent verbatim,
UIComponent component)
Add verbatim as a sibling of component in component in the parent's child list. |
protected abstract UIComponent |
createComponent(FacesContext context,
String newId)
Create and return a new child component of the type returned by calling getComponentType() . |
protected UIOutput |
createVerbatimComponent()
Use the Application instance to create a new component
with the following characteristics. |
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. |
int |
doAfterBody()
Perform any processing necessary to handle the content implications of CASE 4 in the class description. |
int |
doEndTag()
Perform any processing necessary to handle the content implications of CASE 3 in the class description. |
void |
doInitBody()
Prepare for evaluation of the body. |
int |
doStartTag()
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. |
protected void |
encodeBegin()
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. |
protected void |
encodeChildren()
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. |
protected void |
encodeEnd()
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. |
protected UIComponent |
findComponent(FacesContext context)
Find and return the UIComponent , from the component
tree, that corresponds to this tag handler instance. |
BodyContent |
getBodyContent()
|
UIComponent |
getComponentInstance()
Return the UIComponent instance that is associated with
this tag instance. |
boolean |
getCreated()
Return true if we dynamically created a new component
instance during execution of this tag. |
protected List<String> |
getCreatedComponents()
Returns the List of UIComponent ids created or
located by nested UIComponentTag s while processing the current
request. |
protected int |
getDoAfterBodyValue()
Return the flag value that should be returned from the doAfterBody() method when it is called. |
protected int |
getDoEndValue()
Return the flag value that should be returned from the doEnd() method when it is called. |
protected int |
getDoStartValue()
Return the flag value that should be returned from the doStart() method when it is called. |
protected FacesContext |
getFacesContext()
Return the FacesContext instance for the current
request. |
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. |
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). |
protected String |
getId()
Return the id value assigned by the page author. |
protected int |
getIndexOfNextChildTag()
Return the index of the next child to be added as a child of this tag. |
String |
getJspId()
|
Tag |
getParent()
Return the Tag that is the parent of this instance. |
static UIComponentClassicTagBase |
getParentUIComponentClassicTagBase(PageContext context)
Locate and return the nearest enclosing UIComponentClassicTagBase
if any; otherwise, return null . |
JspWriter |
getPreviousOut()
Get the JspWriter from our BodyContent . |
protected abstract boolean |
hasBinding()
Return true if this component has a
non-null binding attribute. |
void |
release()
Release any resources allocated during the execution of this tag handler. |
void |
setBodyContent(BodyContent bodyContent)
Set the bodyContent for this tag handler. |
void |
setId(String id)
Set the component identifier for our component. |
void |
setJspId(String id)
Defined on JspIdConsumer . |
void |
setPageContext(PageContext pageContext)
Set the PageContext of the page containing this
tag instance. |
void |
setParent(Tag parent)
Set the Tag that is the parent of this instance. |
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. |
protected void |
setupResponseWriter()
Set up the ResponseWriter for the
current response, if this has not been done already. |
Methods inherited from class javax.faces.webapp.UIComponentTagBase |
---|
getComponentType, getELContext, getRendererType |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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()
方法时应该从该方法返回的标志值。子类可重写此方法,以返回相应的值。
Throws | JspException:
导致 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 causedoStart()
to throw an exception
protected int
getDoEndValue() throws JspException
返回调用 doEnd()
方法时应该从该方法返回的标志值。子类可重写此方法,以返回相应的值。
Throws | JspException:
导致 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 causedoEnd()
to throw an exception
protected void
encodeBegin() throws java.io.IOException
委托给相应 UIComponent
的 encodeBegin()
方法。此方法从 doStartTag()
调用。通常,代理是无条件发生的,但是此方法有所不同,高级标记可以有条件地执行此调用。
Throws | java.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 correspondingUIComponent
. This method is called fromdoStartTag()
. 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
委托给相应 UIComponent
的 encodeChildren()
方法。此方法从 doStartTag()
调用。通常,代理是无条件发生的,但是此方法有所不同,高级标记可以有条件地执行此调用。
Throws | java.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 correspondingUIComponent
. This method is called fromdoStartTag()
. 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
委托给相应 UIComponent
的 encodeEnd()
方法。此方法从 doStartTag()
调用。通常,代理是无条件发生的,但是此方法有所不同,高级标记可以有条件地执行此调用。
Throws | java.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 correspondingUIComponent
. This method is called fromdoStartTag()
. 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 interfaceTag
- Parameters:
pageContext
- The enclosingPageContext
public Tag
getParent()
返回作为此实例父组件的 Tag
。
getParent
public Tag getParent()
Return the
Tag
that is the parent of this instance.- 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.- Parameters:
parent
- The new parentTag
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。定位或创建组件的过程如下:
- 如果之前找到了此组件,则返回它。
- 通过查找父
UIComponentTag
实例并请求其组件定位父组件。如果没有父UIComponentTag
实例,则此标记表示根组件,因此应从当前的Tree
中获取它并返回。 - 如果此
UIComponentTag
实例有facetName
属性集,则向父UIComponent
请求具有此名称的 facet。如果找不到,则创建一个,使用新组件作为参数调用setProperties()
,并以此名称注册它。返回找到或创建的 facetUIComponent
。 - 确定要分配给新组件的组件 ID,如下所示:如果此
UIComponentTag
有一个id
属性集,则使用该值;否则,生成一个标识符,并保证每次处理页面时此UIComponent
都有相同的标识符(即基于所有不带id
属性集的UIComponentTag
实例的位置)。 - 向父
UIComponent
请求带有此标识符的子组件。如果找不到,则创建一个,使用新组件作为参数调用setProperties()
,并将其注册为具有此标识符的子组件。返回找到或创建的子UIComponent
。
创建组件时,过程如下:
- 通过调用
UIComponentTag#getComponentType
获取组件类型 - 如果组件有
binding
属性,则根据其创建一个表达式,并使用该表达式、FacesContext
和组件类型调用Application#createComponent
。使用关键字"binding"
存储该表达式。 - 否则,调用
Application#createComponent
,只有组件类型参数。 - 调用
setProperties()
。 - 将新组件添加为其父组件的子组件或 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 suchUIComponent
, create one and add it as a child or facet of theUIComponent
associated with our nearest enclosingUIComponentTag
. The process for locating or creating the component is:- If we have previously located this component, return it.
- Locate the parent component by looking for a parent
UIComponentTag
instance, and ask it for its component. If there is no parentUIComponentTag
instance, this tag represents the root component, so get it from the currentTree
and return it. - If this
UIComponentTag
instance has thefacetName
attribute set, ask the parentUIComponent
for a facet with this name. If not found, create one, callsetProperties()
with the new component as a parameter, and register it under this name. Return the found or created facetUIComponent
. - Determine the component id to be assigned to the new
component, as follows: if this
UIComponentTag
has anid
attribute set, use that value; otherwise, generate an identifier that is guaranteed to be the same for thisUIComponent
every time this page is processed (i.e. one based on the location of allUIComponentTag
instances without anid
attribute set). - Ask the parent
UIComponent
for a child with this identifier. If not found, create one, callsetProperties()
with the new component as a parameter, and register it as a child with this identifier. Return the found or created childUIComponent
.
When creating a component, the process is:
- Retrieve the component type by calling
UIComponentTagBase.getComponentType()
- If the component has a
binding
attribute, create an expression from it, and callApplication.createComponent(java.lang.String)
with that expression, theFacesContext
, and the component type. Store the expression using the key"binding"
. - Otherwise, call
Application.createComponent(java.lang.String)
with only the component type. - Call
setProperties()
. - 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, returnnull
.- 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 classUIComponentTagBase
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 nestedUIComponentTag
s processing this request.- Specified by:
addChild
in classUIComponentTagBase
- 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
UIComponentTag
s processing this request.- Specified by:
addFacet
in classUIComponentTagBase
- 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
实例创建带有以下特征的新组件。
componentType
为 javax.faces.HtmlOutputText
。
transient
为 true
。
escape
为 false
。
id
为 FacesContext.getViewRoot().createUniqueId()
createVerbatimComponent
protected UIOutput createVerbatimComponent()
Use the
Application
instance to create a new component with the following characteristics.componentType
isjavax.faces.HtmlOutputText
.transient
istrue
.escape
isfalse
.id
isFacesContext.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 1
或 CASE 2
覆盖的所有内容。
默认实现足以满足大多数组件,要实现此次要需求,它可以调用 #getParentUIComponentClassicTagBase
并对结果调用 #createVerbatimComponentFromBodyContent
。然后通过调用 #addVerbatimBeforeComponent
将返回的组件添加到树中此标记实例的实际组件之前。
在返回之前,组件被推送到此响应的组件堆栈中,以便 #getParentUIComponentClassicTagBase
方法能够正常工作。
要返回的标志值可以通过调用 getDoStartValue()
方法获取,如果它的标记子类不希望使用默认值,则可以重写该方法。
Throws | JspException: 如果发生错误 |
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 transientUIOutput
component to be created and placed in the tree before theUIComponent
instance for this tag. The value of thisUIOutput
component must include anything covered byCASE 1
orCASE 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 callingcreateVerbatimComponentFromBodyContent()
on the result. It then adds the returned component to the tree before the actual component for this tag instance instance by callingaddVerbatimBeforeComponent(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 interfaceTag
- 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()
方法获取,如果它的标记子类不希望使用默认值,则可以重写该方法。
Throws | JspException: 如果发生错误 |
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 byUIComponentTag
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 byUIComponentTag
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.- Retrieve from the
- 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.
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_BODY
或 EVAL_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, beforedoInitiBody()
. This method will not be invoked for empty tags or for non-empty tags whosedoStartTag()
method returnsSKIP_BODY
orEVAL_BODY_INCLUDE
.- Specified by:
setBodyContent
in interfaceBodyTag
- Parameters:
bodyContent
- The newBodyContent
for this tag- See Also:
BodyTag.doInitBody()
,IterationTag.doAfterBody()
public JspWriter
getPreviousOut()
从 BodyContent
获取 JspWriter
。
getPreviousOut
public JspWriter getPreviousOut()
Get the
JspWriter
from ourBodyContent
.
public BodyContent
getBodyContent()
英文文档:
getBodyContent
public BodyContent getBodyContent()
public void
doInitBody() throws JspException
准备对正文求值。此方法由 JSP 页面实现对象在 setBodyContent()
之后并在第一次对正文求值之前调用。对于空标记或者 doStartTag()
方法返回 SKIP_BODY
或 EVAL_BODY_INCLUDE
的非空标记,不调用此方法。
Throws | JspException: 如果遇到错误 |
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 whosedoStartTag()
method returnsSKIP_BODY
orEVAL_BODY_INCLUDE
.- Specified by:
doInitBody
in interfaceBodyTag
- Throws:
JspException
- if an error is encountered- See Also:
IterationTag.doAfterBody()
public int
doAfterBody() throws JspException
执行任何必要的处理,以处理与类描述 CASE 4 类似的情况。
返回 #getDoAfterBodyValue
的结果
Throws | JspException: 如果遇到错误 |
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 interfaceIterationTag
- 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 开头。 |
Throws | IllegalArgumentException:
如果参数为非 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 anIllegalArgumentException
- Specified by:
setId
in classUIComponentTagBase
- Parameters:
id
- The new component identifier. This may not start withUIViewRoot.UNIQUE_ID_PREFIX
.- Throws:
IllegalArgumentException
- if the argument is non-null
and starts withUIViewRoot.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, ifgetJspId()
returns non-null
, prependUNIQUE_ID_PREFIX
to thejspId
and return the result.
protected java.util.List<E>
getCreatedComponents()
返回处理当前请求期间嵌套的 UIComponentTag
创建或定位的 UIComponent
ID List
。
getCreatedComponents
protected List<String> getCreatedComponents()
- Returns the
List
ofUIComponent
ids created or located by nestedUIComponentTag
s 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 beforedoStartTag()
. 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 interfaceJspIdConsumer
- 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()
方法。支持额外属性 foo
和 bar
的典型实现如下所示:
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 theUIComponent
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 propertiesfoo
andbar
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 therendered
property is specified for this tag handler instance.rendererType
- Set if thegetRendererType()
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 thisUIComponentTag
has a non-nullbinding
attribute, this is done by callApplication.createComponent(java.lang.String)
with the expression created for thebinding
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 requestnewId
- 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 thebinding
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 ofdoStartTag()
anddoEndTag()
on this tag instance.- Specified by:
getComponentInstance
in classUIComponentTagBase
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 ofdoStartTag()
anddoEndTag()
on this tag instance.- Specified by:
getCreated
in classUIComponentTagBase
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 ofdoStartTag()
through the end ofdoEndTag()
for each tag instance.- Specified by:
getFacesContext
in classUIComponentTagBase
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).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!