UIOutput (Java EE 5)

Java EE API


javax.faces.component Class UIOutput

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIOutput
All Implemented Interfaces:
StateHolder, ValueHolder
Direct Known Subclasses:
HtmlOutputFormat, HtmlOutputLabel, HtmlOutputLink, HtmlOutputText, UIInput

public class UIOutput
extends UIComponentBase
implements ValueHolder

Implements: ValueHolder

UIOutput 是包含一个要显示给用户的值的 UIComponent,可以选择通过值表达式从模型层 Bean 中获取该值。用户无法直接修改呈现的值;它仅用于显示目的。

在请求处理生命周期的呈现响应 阶段,必须根据以下规则,将此组件的当前值转换为 String(如果它还不是 String 的话):

  • 如果当前值不为 null,而且也不是 String,定位用于转换的 Converter(如果有),如下所示:
    • 如果 getConverter() 返回非 null Converter,则使用该 Converter,否则,
    • 如果将当前值的类传递给 Application.createConverter(Class) 而它返回非 null Converter,则使用该 Converter。
  • 如果当前值不是 null 且找到了 Converter,则调用其 getAsString() 方法执行转换。
  • 如果当前值不是 null,但未找到 Converter,则调用当前值的 toString() 来执行转换。

默认情况下,rendererType 属性必须设置为 "javax.faces.Text"。可以调用 setRendererType() 方法更改此值。

英文文档:

UIOutput is a UIComponent that has a value, optionally retrieved from a model tier bean via a value expression, that is displayed to the user. The user cannot directly modify the rendered value; it is for display purposes only.

During the Render Response phase of the request processing lifecycle, the current value of this component must be converted to a String (if it is not already), according to the following rules:

  • If the current value is not null, and is not already a String, locate a Converter (if any) to use for the conversion, as follows:
    • If getConverter() returns a non-null Converter, use that one, otherwise
    • If Application.createConverter(Class), passing the current value's class, returns a non-null Converter, use that one.
  • If the current value is not null and a Converter was located, call its getAsString() method to perform the conversion.
  • If the current value is not null but no Converter was located, call toString() on the current value to perform the conversion.

By default, the rendererType property must be set to "javax.faces.Text". This value can be changed by calling the setRendererType() method.


Field Summary
static String
static String
 
Fields inherited from class javax.faces.component.UIComponent
 
Constructor Summary
 
Method Summary
 Converter
 String
 Object
 Object
 void
 Object
 void
 void
 
Methods inherited from class javax.faces.component.UIComponentBase
 
Methods inherited from class javax.faces.component.UIComponent
 
Methods inherited from class java.lang.Object
 

Field Detail

英文文档:

COMPONENT_TYPE

public static final String COMPONENT_TYPE

The standard component type for this component.

See Also:
Constant Field Values


英文文档:

COMPONENT_FAMILY

public static final String COMPONENT_FAMILY

The standard component family for this component.

See Also:
Constant Field Values

Constructor Detail

public UIOutput()

使用默认属性值创建新的 UIOutput 实例。

英文文档:

UIOutput

public UIOutput()

Create a new UIOutput instance with default property values.

Method Detail

public String getFamily()
英文文档:

getFamily

public String getFamily()
Description copied from class: UIComponent

Return the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the rendererType property, may be used to select the appropriate Renderer for this component instance.

Specified by:
getFamily in class UIComponent

public Converter getConverter()
英文文档:

getConverter

public Converter getConverter()
Description copied from interface: ValueHolder

Return the Converter (if any) that is registered for this UIComponent.

Specified by:
getConverter in interface ValueHolder

public void setConverter(Converter converter)
英文文档:

setConverter

public void setConverter(Converter converter)
Description copied from interface: ValueHolder

Set the Converter (if any) that is registered for this UIComponent.

Specified by:
setConverter in interface ValueHolder
Parameters:
converter - New Converter (or null)

public Object getLocalValue()
英文文档:

getLocalValue

public Object getLocalValue()
Description copied from interface: ValueHolder

Return the local value of this UIComponent (if any), without evaluating any associated ValueExpression.

Specified by:
getLocalValue in interface ValueHolder

public Object getValue()
英文文档:

getValue

public Object getValue()
Description copied from interface: ValueHolder

Gets the value of this UIComponent. First, consult the local value property of this component. If non-null return it. If null, see if we have a ValueExpression for the value property. If so, return the result of evaluating the property, otherwise return null. Note that because the specification for UIComponent.setValueBinding(java.lang.String, javax.faces.el.ValueBinding) requires a call through to UIComponent.setValueExpression(java.lang.String, javax.el.ValueExpression), legacy tags will continue to work.

Specified by:
getValue in interface ValueHolder

public void setValue(Object value)
英文文档:

setValue

public void setValue(Object value)
Description copied from interface: ValueHolder

Set the value of this UIComponent (if any).

Specified by:
setValue in interface ValueHolder
Parameters:
value - The new local value

public Object saveState(FacesContext context)
英文文档:

saveState

public Object saveState(FacesContext context)
Description copied from interface: StateHolder

Gets the state of the instance as a Serializable Object.

If the class that implements this interface has references to instances that implement StateHolder (such as a UIComponent with event handlers, validators, etc.) this method must call the StateHolder.saveState(javax.faces.context.FacesContext) method on all those instances as well. This method must not save the state of children and facets. That is done via the StateManager

This method must not alter the state of the implementing object. In other words, after executing this code:

 Object state = component.saveState(facesContext);
 

component should be the same as before executing it.

The return from this method must be Serializable

Specified by:
saveState in interface StateHolder
Overrides:
saveState in class UIComponentBase

public void restoreState(FacesContext context, Object state)
英文文档:

restoreState

public void restoreState(FacesContext context,
                         Object state)
Description copied from interface: StateHolder

Perform any processing required to restore the state from the entries in the state Object.

If the class that implements this interface has references to instances that also implement StateHolder (such as a UIComponent with event handlers, validators, etc.) this method must call the StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object) method on all those instances as well.

Specified by:
restoreState in interface StateHolder
Overrides:
restoreState in class UIComponentBase


Submit a bug or feature

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

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

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