|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.faces.component Class UICommand
java.lang.Objectjavax.faces.component.UIComponent
javax.faces.component.UIComponentBase
javax.faces.component.UICommand
- All Implemented Interfaces:
- ActionSource, ActionSource2, StateHolder
- Direct Known Subclasses:
- HtmlCommandButton, HtmlCommandLink
public class UICommand
- extends UIComponentBase
- implements ActionSource2
UICommand 是一个 UIComponent,它表示当用户将其激活时,将触发特定于应用程序的 "command" 或 "action" 的用户界面组件。此类组件通常呈现为按钮开关、菜单项或超链接。
当此 UICommand 的 decode() 方法或其相应的 Renderer 检测到此控件已被激活,它将把一个 ActionEvent 加入队列。之后,broadcast() 方法将确保此事件广播到所有感兴趣的侦听器。
将按以下顺序调用侦听器:
ActionListener,按它们注册的顺序。- "actionListener"
MethodExpression(它将覆盖设置为MethodBinding的 "actionListener")。 - 从
Application中获取到的默认ActionListener- 并且因此包含任何连接的 "action"MethodExpression。
默认情况下,rendererType 属性必须设置为 "javax.faces.Button"。可以调用 setRendererType() 方法更改此值。
UICommand is a UIComponent that represents
a user interface component which, when activated by the user, triggers
an application specific "command" or "action". Such a component is
typically rendered as a push button, a menu item, or a hyperlink.
When the decode() method of this UICommand, or
its corresponding Renderer, detects that this control has been
activated, it will queue an ActionEvent.
Later on, the broadcast() method will ensure that this
event is broadcast to all interested listeners.
Listeners will be invoked in the following order:
ActionListeners, in the order in which they were registered.- The "actionListener"
MethodExpression(which will cover the "actionListener" that was set as aMethodBinding). - The default
ActionListener, retrieved from theApplication- and therefore, any attached "action"MethodExpression.
By default, the rendererType property must be set to
"javax.faces.Button". This value can be changed by calling the
setRendererType() method.
| Field Summary | |
|---|---|
static String |
COMPONENT_FAMILY
The standard component family for this component. |
static String |
COMPONENT_TYPE
The standard component type for this component. |
| Fields inherited from class javax.faces.component.UIComponent |
|---|
bindings |
| Constructor Summary | |
|---|---|
UICommand()
Create a new UICommand instance with default property
values. |
|
| Method Summary | |
|---|---|
void |
addActionListener(ActionListener listener)
Add a new ActionListener to the set of listeners interested
in being notified when ActionEvents occur. |
void |
broadcast(FacesEvent event)
In addition to to the default UIComponent.broadcast(javax.faces.event.FacesEvent)
processing, pass the ActionEvent being broadcast to the
method referenced by actionListener (if any),
and to the default ActionListener registered on the
Application. |
MethodBinding |
getAction()
Deprecated. This has been replaced by getActionExpression(). |
MethodExpression |
getActionExpression()
Return the MethodExpression pointing at the application
action to be invoked, if this UIComponent is activated by
the user, during the Apply Request Values or Invoke
Application phase of the request processing lifecycle,
depending on the value of the immediate
property. |
MethodBinding |
getActionListener()
Deprecated. Use getActionListeners() instead. |
ActionListener[] |
getActionListeners()
Return the set of registered ActionListeners for this
ActionSource instance. |
String |
getFamily()
Return the identifier of the component family to which this component belongs. |
Object |
getValue()
Returns the value property of the
UICommand. |
boolean |
isImmediate()
Return a flag indicating that the default ActionListener
provided by the JavaServer Faces implementation should be executed
immediately (that is, during Apply Request Values phase
of the request processing lifecycle), rather than waiting until the
Invoke Application phase. |
void |
queueEvent(FacesEvent e)
Intercept queueEvent and, for ActionEvents,
mark the phaseId for the event to be
PhaseId.APPLY_REQUEST_VALUES if the
immediate flag is true,
PhaseId.INVOKE_APPLICATION otherwise. |
void |
removeActionListener(ActionListener listener)
Remove an existing ActionListener (if any) from the set of
listeners interested in being notified when ActionEvents
occur. |
void |
restoreState(FacesContext context,
Object state)
Perform any processing required to restore the state from the entries in the state Object. |
Object |
saveState(FacesContext context)
Gets the state of the instance as a Serializable Object. |
void |
setAction(MethodBinding action)
Deprecated. This has been replaced by setActionExpression(javax.el.MethodExpression). |
void |
setActionExpression(MethodExpression actionExpression)
Set the MethodExpression pointing at the appication
action to be invoked, if this UIComponent is activated by
the user, during the Apply Request Values or Invoke
Application phase of the request processing lifecycle,
depending on the value of the immediate
property. |
void |
setActionListener(MethodBinding actionListener)
Deprecated. This has been replaced by addActionListener(javax.faces.event.ActionListener). |
void |
setImmediate(boolean immediate)
Set the "immediate execution" flag for this UIComponent. |
void |
setValue(Object value)
Sets the value property of the UICommand. |
| Methods inherited from class javax.faces.component.UIComponent |
|---|
encodeAll, getContainerClientId, getValueExpression, setValueExpression |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 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
UICommand()
使用默认属性值创建新的 UICommand 实例。
UICommand
public UICommand()
Create a new
UICommandinstance 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
rendererTypeproperty, may be used to select the appropriateRendererfor this component instance.- Specified by:
getFamilyin classUIComponent
public MethodBinding
getAction()
NullPointerException
如果实现类还实现了 ActionSource2,则此方法的实现必须调用 ActionSource2#getActionExpression 并检查该结果。如果结果来自以前对 #setAction 的调用,则从结果中提取 MethodBinding 并将其返回。否则,包装返回的 MethodBinding 实现中的 javax.el.MethodExpression 并将其返回。
如果实现类没有实现 ActionSource2,则返回一个 MethodBinding,该 MethodBinding 指向用户激活此 UIComponent 时要在请求处理生命周期的应用请求值 或调用应用程序 阶段(取决于 immediate 属性的值)调用的应用程序操作。
| deprecated |
此方法已由 #getActionExpression 替代。 |
getAction
public MethodBinding getAction()
- Deprecated. This has been replaced by
getActionExpression(). If the implementing class also implements
ActionSource2, the implementation of this method must call through toActionSource2.getActionExpression()and examine the result. If the result came from a previous call toActionSource.setAction(javax.faces.el.MethodBinding), extract theMethodBindingfrom it and return it. Otherwise, wrap the returnedMethodExpressionin aMethodBindingimplementation, and return it.If the implementing class does not implement
ActionSource2, return theMethodBindingpointing at the application action to be invoked, if thisUIComponentis activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediateproperty.- Specified by:
getActionin interfaceActionSource
public void
setAction(MethodBinding action)
NullPointerException
如果实现类还实现了 ActionSource2,则此方法的实现必须在实现 javax.el.MethodExpression 的类中包装参数 action,并调用 ActionSource2#setActionExpression,同时传递包装的 action。
如果实现类没有实现 ActionSource2,则设置一个 MethodBinding,该 MethodBinding 指向用户激活此 UIComponent 时要在请求处理生命周期的应用请求值 或调用应用程序 阶段(取决于 immediate 属性的值)调用的应用程序操作。
此表达式所引用的任何方法都必须是公共的,返回类型为 String,并且不接受任何参数。
| deprecated |
此方法已由 #setActionExpression(javax.el.MethodExpression) 替代。 |
setAction
public void setAction(MethodBinding action)
- Deprecated. This has been replaced by
setActionExpression(javax.el.MethodExpression). If the implementing class also implements
ActionSource2, the implementation of this method must wrap the argumentactionin a class that implementsMethodExpressionand call through toActionSource2.setActionExpression(javax.el.MethodExpression), passing the wrappedaction.If the implementing class does not implement
ActionSource2, set theMethodBindingpointing at the appication action to be invoked, if thisUIComponentis activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediateproperty.Any method referenced by such an expression must be public, with a return type of
String, and accept no parameters.- Specified by:
setActionin interfaceActionSource
- Parameters:
action- The new MethodBinding expression
public MethodBinding
getActionListener()
NullPointerException
如果以前没有为此实例调用过 #setActionListener,则此方法必须返回 null。如果调用过 #setActionListener,则此方法必须返回原先传递给 #setActionListener 的那个 MethodBinding 实例。
用户激活此 UIComponent 时要调用的方法将在请求处理生命周期的应用请求值 或调用应用程序 阶段(取决于 immediate 属性的值)调用。
| deprecated |
请改用 #getActionListeners。 |
getActionListener
public MethodBinding getActionListener()
- Deprecated. Use
getActionListeners()instead. If
ActionSource.setActionListener(javax.faces.el.MethodBinding)was not previously called for this instance, this method must returnnull. If it was called, this method must return the exactMethodBindinginstance that was passed toActionSource.setActionListener(javax.faces.el.MethodBinding).The method to be invoked, if this
UIComponentis activated by the user, will be called during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending upon the value of theimmediateproperty.- Specified by:
getActionListenerin interfaceActionSource
public void
setActionListener(MethodBinding actionListener)
NullPointerException
在 ActionListener 的实现中包装参数 actionListener,并将其存储在支持 #getActionListeners 方法的内部数据结构中,小心地重写通过以前调用 setActionListener 存储的任何实例。
此表达式所引用的任何方法都必须是公共的,返回类型为 void,并接受类型为 ActionEvent 的单个参数。
| deprecated |
此方法已由 #addActionListener(javax.faces.event.ActionListener) 替代。 |
setActionListener
public void setActionListener(MethodBinding actionListener)
- Deprecated. This has been replaced by
addActionListener(javax.faces.event.ActionListener). Wrap the argument
actionListenerin an implementation ofActionListenerand store it in the internal data structure that backs theActionSource.getActionListeners()method, taking care to over-write any instance that was stored by a previous call tosetActionListener.Any method referenced by such an expression must be public, with a return type of
void, and accept a single parameter of typeActionEvent.- Specified by:
setActionListenerin interfaceActionSource
- Parameters:
actionListener- The new method binding expression
public boolean
isImmediate()
英文文档:
isImmediate
public boolean isImmediate()
- Description copied from interface:
ActionSource Return a flag indicating that the default
ActionListenerprovided by the JavaServer Faces implementation should be executed immediately (that is, during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase. The default value for this property must befalse.- Specified by:
isImmediatein interfaceActionSource
public void
setImmediate(boolean immediate)
英文文档:
setImmediate
public void setImmediate(boolean immediate)
- Description copied from interface:
ActionSource Set the "immediate execution" flag for this
UIComponent.- Specified by:
setImmediatein interfaceActionSource
- Parameters:
immediate- The new immediate execution flag
public Object
getValue()
返回 UICommand 的 value 属性。这通常呈现为一个标签。
getValue
public Object getValue()
Returns the
valueproperty of theUICommand. This is most often rendered as a label.
public void
setValue(Object value)
设置 UICommand 的 value 属性。这通常呈现为一个标签。
| value | 新值 |
setValue
public void setValue(Object value)
Sets the
valueproperty of theUICommand. This is most often rendered as a label.- Parameters:
value- the new value
public MethodExpression
getActionExpression()
英文文档:
getActionExpression
public MethodExpression getActionExpression()
- Description copied from interface:
ActionSource2 Return the
MethodExpressionpointing at the application action to be invoked, if thisUIComponentis activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediateproperty.Note that it's possible that the returned
MethodExpressionis just a wrapper around aMethodBindinginstance whith was set by a call toActionSource.setAction(javax.faces.el.MethodBinding). This makes it possible for the defaultActionListenerto continue to work properly with older components.- Specified by:
getActionExpressionin interfaceActionSource2
public void
setActionExpression(MethodExpression actionExpression)
英文文档:
setActionExpression
public void setActionExpression(MethodExpression actionExpression)
- Description copied from interface:
ActionSource2 Set the
MethodExpressionpointing at the appication action to be invoked, if thisUIComponentis activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediateproperty.Any method referenced by such an expression must be public, with a return type of
String, and accept no parameters.- Specified by:
setActionExpressionin interfaceActionSource2
- Parameters:
actionExpression- The new method expression
public void
addActionListener(ActionListener listener)
| Throws | NullPointerException:
NullPointerException
如果 listener 为 null |
addActionListener
public void addActionListener(ActionListener listener)
- Description copied from interface:
ActionSource Add a new
ActionListenerto the set of listeners interested in being notified whenActionEvents occur.- Specified by:
addActionListenerin interfaceActionSource
- Parameters:
listener- TheActionListenerto be added- Throws:
NullPointerException- iflistenerisnull
public ActionListener[]
getActionListeners()
英文文档:
getActionListeners
public ActionListener[] getActionListeners()
- Description copied from interface:
ActionSource Return the set of registered
ActionListeners for thisActionSourceinstance. If there are no registered listeners, a zero-length array is returned.- Specified by:
getActionListenersin interfaceActionSource
public void
removeActionListener(ActionListener listener)
| Throws | NullPointerException:
NullPointerException
如果 listener 为 null |
removeActionListener
public void removeActionListener(ActionListener listener)
- Description copied from interface:
ActionSource Remove an existing
ActionListener(if any) from the set of listeners interested in being notified whenActionEvents occur.- Specified by:
removeActionListenerin interfaceActionSource
- Parameters:
listener- TheActionListenerto be removed- Throws:
NullPointerException- iflistenerisnull
public Object
saveState(FacesContext context)
英文文档:
saveState
public Object saveState(FacesContext context)
- Description copied from interface:
StateHolder Gets the state of the instance as a
SerializableObject.If the class that implements this interface has references to instances that implement StateHolder (such as a
UIComponentwith event handlers, validators, etc.) this method must call theStateHolder.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 theStateManagerThis method must not alter the state of the implementing object. In other words, after executing this code:
Object state = component.saveState(facesContext);
componentshould be the same as before executing it.The return from this method must be
Serializable- Specified by:
saveStatein interfaceStateHolder- Overrides:
saveStatein classUIComponentBase
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
UIComponentwith event handlers, validators, etc.) this method must call theStateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)method on all those instances as well.- Specified by:
restoreStatein interfaceStateHolder- Overrides:
restoreStatein classUIComponentBase
public void
broadcast(FacesEvent event) throws AbortProcessingException
除了默认的 UIComponent#broadcast 处理外,将要广播的 ActionEvent 传递给 actionListener 引用的方法(如果有),以及传递给 javax.faces.application.Application 上注册的默认 ActionListener。
| event |
要广播的 FacesEvent |
| Throws | AbortProcessingException: 通知 JavaServer Face 实现不应该继续处理当前事件 |
| Throws | IllegalArgumentException:
如果此组件不支持此 FacesEvent 的实现类 |
| Throws | NullPointerException:
如果 event 为 null |
broadcast
public void broadcast(FacesEvent event) throws AbortProcessingException
In addition to to the default
UIComponent.broadcast(javax.faces.event.FacesEvent)processing, pass theActionEventbeing broadcast to the method referenced byactionListener(if any), and to the defaultActionListenerregistered on theApplication.- Overrides:
broadcastin classUIComponentBase
- Parameters:
event-FacesEventto be broadcast- Throws:
AbortProcessingException- Signal the JavaServer Faces implementation that no further processing on the current event should be performedIllegalArgumentException- if the implementation class of thisFacesEventis not supported by this componentNullPointerException- ifeventisnull
public void
queueEvent(FacesEvent e)
截取 ActionEvent 的 queueEvent,且如果 immediate 标志为 true,则将事件的 phaseId 标记为 PhaseId.APPLY_REQUEST_VALUES,否则标记为 PhaseId.INVOKE_APPLICATION。
queueEvent
public void queueEvent(FacesEvent e)
Intercept
queueEventand, forActionEvents, mark the phaseId for the event to bePhaseId.APPLY_REQUEST_VALUESif theimmediateflag is true,PhaseId.INVOKE_APPLICATIONotherwise.- Overrides:
queueEventin classUIComponentBase
- Parameters:
e-FacesEventto be queued
|
|
|||||||||
| 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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!
