ActionSource (Java EE 5)

Java EE API


javax.faces.component Interface ActionSource

All Known Subinterfaces:
ActionSource2
All Known Implementing Classes:
HtmlCommandButton, HtmlCommandLink, UICommand

public interface ActionSource

Implemented by: ActionSource2

ActionSource 是一个接口,可以由要作为 ActionEvent 源(包括要具有通过默认 ActionListener 机制调用应用程序操作的能力)的任何具体 UIComponent 实现。

英文文档:

ActionSource is an interface that may be implemented by any concrete UIComponent that wishes to be a source of ActionEvents, including the ability to invoke application actions via the default ActionListener mechanism.


Method Summary
 void
 MethodBinding
 MethodBinding
 ActionListener[]
 boolean
 void
 void
 void
 void
 

Method Detail

public MethodBinding getAction()

如果实现类还实现了 ActionSource2,则此方法的实现必须调用 ActionSource2#getActionExpression 并检查该结果。如果结果来自以前对 #setAction 的调用,则从结果中提取 MethodBinding 并将其返回。否则,包装返回的 MethodBinding 实现中的 javax.el.MethodExpression 并将其返回。

如果实现类没有实现 ActionSource2,则返回一个 MethodBinding,该 MethodBinding 指向用户激活此 UIComponent 时要在请求处理生命周期的应用请求值调用应用程序 阶段(取决于 immediate 属性的值)调用的应用程序操作。

deprecated 此方法已由 ActionSource2#getActionExpression 取代。
英文文档:

getAction

MethodBinding getAction()
Deprecated. This has been replaced by ActionSource2.getActionExpression().

If the implementing class also implements ActionSource2, the implementation of this method must call through to ActionSource2.getActionExpression() and examine the result. If the result came from a previous call to setAction(javax.faces.el.MethodBinding), extract the MethodBinding from it and return it. Otherwise, wrap the returned MethodExpression in a MethodBinding implementation, and return it.

If the implementing class does not implement ActionSource2, return the MethodBindingpointing 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.


public void setAction(MethodBinding action)

如果实现类还实现了 ActionSource2,则此方法的实现必须在实现 javax.el.MethodExpression 的类中包装参数 action,并调用 ActionSource2#setActionExpression,同时传递包装的 action

如果实现类没有实现 ActionSource2,则设置一个 MethodBinding,该 MethodBinding 指向用户激活此 UIComponent 时要在请求处理生命周期的应用请求值调用应用程序 阶段(取决于 immediate 属性的值)调用的应用程序操作。

此表达式所引用的任何方法都必须是公共的,返回类型为 String,并且不接受任何参数。

action 新的 MethodBinding 表达式
deprecated 此方法已由 setActionExpression(javax.el.MethodExpression) 替代。
英文文档:

setAction

void setAction(MethodBinding action)
Deprecated. This has been replaced by ActionSource2.setActionExpression(javax.el.MethodExpression).

If the implementing class also implements ActionSource2, the implementation of this method must wrap the argument action in a class that implements MethodExpression and call through to ActionSource2.setActionExpression(javax.el.MethodExpression), passing the wrapped action.

If the implementing class does not implement ActionSource2, set the MethodBinding 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.

Any method referenced by such an expression must be public, with a return type of String, and accept no parameters.

Parameters:
action - The new MethodBinding expression

public MethodBinding getActionListener()

如果以前没有为此实例调用过 #setActionListener,则此方法必须返回 null。如果调用过 #setActionListener,则此方法必须返回原先传递给 #setActionListener 的那个 MethodBinding 实例。

用户激活此 UIComponent 时要调用的方法将在请求处理生命周期的应用请求值调用应用程序 阶段(取决于 immediate 属性的值)调用。

deprecated 请改用 #getActionListeners
英文文档:

getActionListener

MethodBinding getActionListener()
Deprecated. Use getActionListeners() instead.

If setActionListener(javax.faces.el.MethodBinding) was not previously called for this instance, this method must return null. If it was called, this method must return the exact MethodBinding instance that was passed to setActionListener(javax.faces.el.MethodBinding).

The method to be invoked, if this UIComponent is 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 the immediate property.


public void setActionListener(MethodBinding actionListener)

ActionListener 的实现中包装参数 actionListener,并将其存储在支持 #getActionListeners 方法的内部数据结构中,小心地重写通过以前调用 setActionListener 存储的任何实例。

此表达式所引用的任何方法都必须是公共的,返回类型为 void,并接受类型为 ActionEvent 的单个参数。

actionListener 新的方法绑定表达式
deprecated 此方法已由 #addActionListener(javax.faces.event.ActionListener) 替代。
英文文档:

setActionListener

void setActionListener(MethodBinding actionListener)
Deprecated. This has been replaced by addActionListener(javax.faces.event.ActionListener).

Wrap the argument actionListener in an implementation of ActionListener and store it in the internal data structure that backs the getActionListeners() method, taking care to over-write any instance that was stored by a previous call to setActionListener.

Any method referenced by such an expression must be public, with a return type of void, and accept a single parameter of type ActionEvent.

Parameters:
actionListener - The new method binding expression

public boolean isImmediate()

返回一个标志,指示 JavaServer Faces 实现提供的默认 ActionListener 应立即执行(即在请求处理生命周期的应用请求值 阶段),而不是等到调用应用程序 阶段执行。此属性的默认值必须为 false

英文文档:

isImmediate

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. The default value for this property must be false.


public void setImmediate(boolean immediate)

设置此 UIComponent 的 "immediate execution" 标志。

immediate 新的立即执行标志
英文文档:

setImmediate

void setImmediate(boolean immediate)

Set the "immediate execution" flag for this UIComponent.

Parameters:
immediate - The new immediate execution flag

public void addActionListener(ActionListener listener)

向希望在发生 ActionEvent 时获得通知的侦听器集合中添加一个新的 ActionListener

listener 要添加的 ActionListener
ThrowsNullPointerException: 如果 listenernull
英文文档:

addActionListener

void addActionListener(ActionListener listener)

Add a new ActionListener to the set of listeners interested in being notified when ActionEvents occur.

Parameters:
listener - The ActionListener to be added
Throws:
NullPointerException - if listener is null

public ActionListener[] getActionListeners()

返回此 ActionSource 实例已注册的 ActionListener 的集合。如果不存在任何已注册侦听器,则返回一个长度为 0 的数组。

英文文档:

getActionListeners

ActionListener[] getActionListeners()

Return the set of registered ActionListeners for this ActionSource instance. If there are no registered listeners, a zero-length array is returned.


public void removeActionListener(ActionListener listener)

从希望在发生 ActionEvent 时获得通知的侦听器集合中移除现有的 ActionListener(如果有)。

listener 要移除的 ActionListener
ThrowsNullPointerException: 如果 listenernull
英文文档:

removeActionListener

void removeActionListener(ActionListener listener)

Remove an existing ActionListener (if any) from the set of listeners interested in being notified when ActionEvents occur.

Parameters:
listener - The ActionListener to be removed
Throws:
NullPointerException - if listener is null


Submit a bug or feature

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

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

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