|
Java EE 5 SDK 深圳电信培训中心.徐海蛟老师. |
||||||||
上一个类 下一个类 | 框架 无框架 | ||||||||
摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 |
javax.faces.component Class UICommand
java.lang.Object javax.faces.component.UIComponent javax.faces.component.UIComponentBase javax.faces.component.UICommand
- 所有已实现的接口:
- ActionSource, ActionSource2, StateHolder
- 直接已知子类:
- HtmlCommandButton, HtmlCommandLink
public class UICommand
- extends UIComponentBase
- implements ActionSource2
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:
ActionListener
s, 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.
字段摘要 | |
---|---|
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 |
构造器摘要 | |
---|---|
UICommand()
Create a new UICommand instance with default property
values. |
方法摘要 | |
---|---|
void |
addActionListener(ActionListener listener)
Add a new ActionListener to the set of listeners interested
in being notified when ActionEvent s 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 ActionListener s 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 ActionEvent s,
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 ActionEvent s
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 . |
类方法继承 javax.faces.component.UIComponent |
---|
encodeAll, getContainerClientId, getValueExpression, setValueExpression |
类方法继承 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
字段详细信息 |
---|
COMPONENT_TYPE
public static final String COMPONENT_TYPE
The standard component type for this component.
- 另请参见:
- 常量字段
COMPONENT_FAMILY
public static final String COMPONENT_FAMILY
The standard component family for this component.
- 另请参见:
- 常量字段
构造器详细信息 |
---|
UICommand
public UICommand()
Create a new
UICommand
instance with default property values.
方法详细信息 |
---|
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 appropriateRenderer
for this component instance.- 规范说明:
getFamily
in classUIComponent
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 theMethodBinding
from it and return it. Otherwise, wrap the returnedMethodExpression
in aMethodBinding
implementation, and return it.If the implementing class does not implement
ActionSource2
, return theMethodBinding
pointing at the application action to be invoked, if thisUIComponent
is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediate
property.- 规范说明:
getAction
in interfaceActionSource
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 argumentaction
in a class that implementsMethodExpression
and call through toActionSource2.setActionExpression(javax.el.MethodExpression)
, passing the wrappedaction
.If the implementing class does not implement
ActionSource2
, set theMethodBinding
pointing at the appication action to be invoked, if thisUIComponent
is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediate
property.Any method referenced by such an expression must be public, with a return type of
String
, and accept no parameters.- 规范说明:
setAction
in interfaceActionSource
- 参数:
action
- The new MethodBinding expression
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 exactMethodBinding
instance that was passed toActionSource.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 theimmediate
property.- 规范说明:
getActionListener
in interfaceActionSource
setActionListener
public void setActionListener(MethodBinding actionListener)
- Deprecated. This has been replaced by
addActionListener(javax.faces.event.ActionListener)
. Wrap the argument
actionListener
in an implementation ofActionListener
and 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
.- 规范说明:
setActionListener
in interfaceActionSource
- 参数:
actionListener
- The new method binding expression
isImmediate
public boolean isImmediate()
- Description copied from interface:
ActionSource
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 befalse
.- 规范说明:
isImmediate
in interfaceActionSource
setImmediate
public void setImmediate(boolean immediate)
- Description copied from interface:
ActionSource
Set the "immediate execution" flag for this
UIComponent
.- 规范说明:
setImmediate
in interfaceActionSource
- 参数:
immediate
- The new immediate execution flag
getValue
public Object getValue()
Returns the
value
property of theUICommand
. This is most often rendered as a label.
setValue
public void setValue(Object value)
Sets the
value
property of theUICommand
. This is most often rendered as a label.- 参数:
value
- the new value
getActionExpression
public MethodExpression getActionExpression()
- Description copied from interface:
ActionSource2
Return the
MethodExpression
pointing at the application action to be invoked, if thisUIComponent
is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediate
property.Note that it's possible that the returned
MethodExpression
is just a wrapper around aMethodBinding
instance whith was set by a call toActionSource.setAction(javax.faces.el.MethodBinding)
. This makes it possible for the defaultActionListener
to continue to work properly with older components.- 规范说明:
getActionExpression
in interfaceActionSource2
setActionExpression
public void setActionExpression(MethodExpression actionExpression)
- Description copied from interface:
ActionSource2
Set the
MethodExpression
pointing at the appication action to be invoked, if thisUIComponent
is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of theimmediate
property.Any method referenced by such an expression must be public, with a return type of
String
, and accept no parameters.- 规范说明:
setActionExpression
in interfaceActionSource2
- 参数:
actionExpression
- The new method expression
addActionListener
public void addActionListener(ActionListener listener)
- Description copied from interface:
ActionSource
Add a new
ActionListener
to the set of listeners interested in being notified whenActionEvent
s occur.- 规范说明:
addActionListener
in interfaceActionSource
- 参数:
listener
- TheActionListener
to be added- 抛出异常:
NullPointerException
- iflistener
isnull
getActionListeners
public ActionListener[] getActionListeners()
- Description copied from interface:
ActionSource
Return the set of registered
ActionListener
s for thisActionSource
instance. If there are no registered listeners, a zero-length array is returned.- 规范说明:
getActionListeners
in interfaceActionSource
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 whenActionEvent
s occur.- 规范说明:
removeActionListener
in interfaceActionSource
- 参数:
listener
- TheActionListener
to be removed- 抛出异常:
NullPointerException
- iflistener
isnull
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 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 theStateManager
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
- 规范说明:
saveState
in interfaceStateHolder
- 重写:
saveState
in classUIComponentBase
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 theStateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
method on all those instances as well.- 规范说明:
restoreState
in interfaceStateHolder
- 重写:
restoreState
in classUIComponentBase
broadcast
public void broadcast(FacesEvent event) throws AbortProcessingException
In addition to to the default
UIComponent.broadcast(javax.faces.event.FacesEvent)
processing, pass theActionEvent
being broadcast to the method referenced byactionListener
(if any), and to the defaultActionListener
registered on theApplication
.- 重写:
broadcast
in classUIComponentBase
- 参数:
event
-FacesEvent
to be broadcast- 抛出异常:
AbortProcessingException
- Signal the JavaServer Faces implementation that no further processing on the current event should be performedIllegalArgumentException
- if the implementation class of thisFacesEvent
is not supported by this componentNullPointerException
- ifevent
isnull
queueEvent
public void queueEvent(FacesEvent e)
Intercept
queueEvent
and, forActionEvent
s, mark the phaseId for the event to bePhaseId.APPLY_REQUEST_VALUES
if theimmediate
flag is true,PhaseId.INVOKE_APPLICATION
otherwise.- 重写:
queueEvent
in classUIComponentBase
- 参数:
e
-FacesEvent
to be queued
|
Java EE 5 SDK 深圳电信培训中心.徐海蛟老师. |
||||||||
上一个类 下一个类 | 框架 无框架 | ||||||||
摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 |
提交错误或意见
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.