|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.click.ActionEventDispatcher
public class ActionEventDispatcher
Provides a control ActionListener event dispatcher.
Please note: this class is meant for component development and can be ignored otherwise. When registering an ActionListener you can specify the callback to occur for a specific event. For example ActionListeners can be registered to fire after the onProcess event. This event can be specified through the constantPOST_ON_PROCESS_EVENT
.
The ClickServlet will notify the ActionEventDispatcher which ActionListeners
to fire. For example, after the onProcess event, the ClickServlet
will notify the dispatcher to fire ActionListeners registered for the
POST_ON_PROCESS_EVENT
(this is the default event when listeners are
fired).
Out of the box ActionEventDispatcher only supports the event
POST_ON_PROCESS_EVENT
(the default).
public class MyLink extends AbstractControl { ... public boolean onProcess() { bindRequestValue(); if (isClicked()) { // Dispatch an action listener event for invocation after // control processing has finished dispatchActionEvent(); } return true; } }In this example if the link is clicked, it then calls
AbstractControl.dispatchActionEvent()
.
This method registers the Control's action listener with ActionEventDispatcher.
The ClickServlet will subsequently invoke the registered
ActionListener.onAction(Control)
method after all the Page controls
onProcess() method have been invoked.
Nested Class Summary | |
---|---|
class |
ActionEventDispatcher.EventHolder
Holds the list of listeners and event sources. |
Field Summary | |
---|---|
static int |
POST_ON_PROCESS_EVENT
Indicates the listener should fire AFTER the onProcess event. |
Constructor Summary | |
---|---|
ActionEventDispatcher()
|
Method Summary | |
---|---|
protected void |
clearEvents()
Clear the event list. |
protected ActionEventDispatcher.EventHolder |
createEventHolder(int event)
Create a new EventHolder instance. |
static void |
dispatchActionEvent(Control source,
ActionListener listener)
Register the event source and event ActionListener to be fired by the ClickServlet once all the controls have been processed. |
static void |
dispatchActionEvent(Control source,
ActionListener listener,
int event)
Register the event source and event ActionListener to be fired by the ClickServlet in the specified event. |
protected void |
errorOccurred(Throwable throwable)
Allow the dispatcher to handle the error that occurred. |
protected boolean |
fireActionEvent(Context context,
Control source,
ActionListener listener,
int event)
Fire the action for the given listener and event source which return true if the page should continue processing. |
protected boolean |
fireActionEvents(Context context)
Fire all the registered action events after the Page Controls have been processed and return true if the page should continue processing. |
protected boolean |
fireActionEvents(Context context,
int event)
Fire all the registered action events for the specified event and return true if the page should continue processing. |
protected boolean |
fireActionEvents(Context context,
List<Control> eventSourceList,
List<ActionListener> eventListenerList,
int event)
Fire the actions for the given listener list and event source list which return true if the page should continue processing. |
protected ActionEventDispatcher.EventHolder |
getEventHolder(int event)
Return the EventHolder for the specified event. |
protected static ActionEventDispatcher |
getThreadLocalDispatcher()
Return the thread local dispatcher instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int POST_ON_PROCESS_EVENT
Constructor Detail |
---|
public ActionEventDispatcher()
Method Detail |
---|
public static void dispatchActionEvent(Control source, ActionListener listener)
POST_ON_PROCESS_EVENT
.
source
- the action event sourcelistener
- the event action listenerdispatchActionEvent(org.apache.click.Control, org.apache.click.ActionListener, int)
public static void dispatchActionEvent(Control source, ActionListener listener, int event)
source
- the action event sourcelistener
- the event action listenerevent
- the specific event to trigger the action eventprotected void errorOccurred(Throwable throwable)
throwable
- the error which occurred during processingprotected void clearEvents()
protected static ActionEventDispatcher getThreadLocalDispatcher()
RuntimeException
- if a ActionEventDispatcher is not available on the
thread.protected boolean fireActionEvents(Context context, List<Control> eventSourceList, List<ActionListener> eventListenerList, int event)
POST_ON_PROCESS_EVENT
.
event.
This method can be overridden if you need to customize the way events
are fired.
context
- the request contexteventSourceList
- the list of source controlseventListenerList
- the list of listeners to fireevent
- the specific event which events to fire
protected boolean fireActionEvents(Context context)
context
- the request context
fireActionEvents(org.apache.click.Context, int)
protected boolean fireActionEvents(Context context, int event)
context
- the request contextevent
- the event which listeners to fire
protected boolean fireActionEvent(Context context, Control source, ActionListener listener, int event)
POST_ON_PROCESS_EVENT
.
This method can be overridden if you need to customize the way events
are fired.
context
- the request contextsource
- the source controllistener
- the listener to fireevent
- the specific event which events to fire
protected ActionEventDispatcher.EventHolder getEventHolder(int event)
event
- the event which EventHolder to retrieve
protected ActionEventDispatcher.EventHolder createEventHolder(int event)
event
- the EventHolder's event
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |