New Component Planning <a4j:queue/>
jbalunas Oct 13, 2008 2:32 PMThe RichFaces team is going to develop a new component that will take ajax event queue's to the next level. We wanted to open the discussion to the community and get feedback and ideas for it.
Below are current plans and open issues. The initial functional spec is http://anonsvn.jboss.org/repos/richfaces/management/design/queue/. This has not been updated from the initial document so several of the items are out of date or in open discussion as outlined below.
Intro
Tag name: <a4j:queue/>
OPEN ISSUE: Should this be <rich:queue/>
This tag will be used to create specific queues that various components can reference and use. Common options can be set to govern the queue. Queue properties can be set in one location (queue element) or overrode by specific components.
To define and reference a new queue:
<a4j:queue name="queue1" /> <h:inputText value="#{foo2.bar1}"> <a:support id="onblur" event="onblur" reRender="bar21" eventsQueue="queue1"/> </h:inputText>
Global Queue
There will be a default or global queue component that can be used by all elements and is enabled by default. This can be referenced using the fully qualified queue name "org.richfaces.queue.global". All components that do not state an eventQueue will use this queue. The global queue is limited to one per view - if more than one defined an exception will be thrown.
If not defined specifically the global queue attributes will be set to the default values.
<a4j:queue name="org.richfaces.queue.global" ... />
OPEN ITEM: Should it be enabled or disabled by default? One option is that this is controlled via a context param.
OPEN ITEM: Should default use of the global queue by all components be adjustable?
QUEUE Attributes and Defaults
Below is a listing of the various attributes that queues can have and what the default setting are.
OPEN ISSUE: how useful is it to be able to set default values for all queues - either via context variables, or a tag in the view?
OPEN ITEM: default values?
-- requestDelay [?]- as document elsewhere
-- timeout [500?] - ms for event timeout
-- limittolist [empty] - as documented elsewhere
-- ignoreDupResponses [true?] - as documented elsewhere
-- size - the time that the queue is allowed to grow to ( -1 = unlimited, 0 = disabled, x = some number)
OPEN ITEM: what is the behavior when the size limit is reached?
- Fire the event immediately
- Reject the event
- throw and exception
- in any of these cases a call back JS method should able to be defined and called if this happens.
As stated above each of these settings can be overridden on a per component basis. For example a components specific event may require DB access and the developer knows that the queue's timeout is not enough. The developer could override the "timeout" attribute for it's specific event.
OPEN ITEM: Is this a good idea, or should the event in question use a different queue?
<a4j:queue name="queue1" timeout="1000"/> <a4j:commandButton eventQueue="queue1" timeout="5000" >
Different ways to use the queues
Queues can be referenced by individual components such as:
<a4j:queue name="queue1" /> <h:inputText value="#{foo2.bar1}"> <a:support id="onblur" event="onblur" reRender="bar21" eventsQueue="queue1"/> </h:inputText> <a4j:commandButton eventQueue="queue1" .. >
Or queues can be referenced by forms so that all richfaces ajax requests in the form will use that queue unless a component specifically sets a different queue:
<h:form> <a4j:queue name="foo2"/> <a4j:commandButton > <!-- uses "foo2" --> <a4j:commandButton eventQueue="queue1" > <!-- uses "queue1" -->
OPEN ITEM: do we limit this to only a4j:form components?
If a queue is references by a component, but a queue with that name does not exist a new a4j:queue will be created with all default settings, and be named as per the component that is calling it.
OPEN ITEM: How is this different than defining a new queue?
Misc
It will be possible to disable a queue and use it simply as a way to set event attributes that can be used by multiple components. This can be done by TBD.
OPEN ITEM: how to disable a queue? Set size to "0", or specifically set a new attribute "enabled="false""?
OPEN ITEM: is this useful? will it be used?
Callbacks: Possible callbacks could be: onExpired, onError, onSizeExceeded. Developers could define corresponding handlers with these attributes.
Some other possible callback: onSubmit, onComplete, onBeforeDomUpdate, etc...
OPEN ITEM: Thoughts?
Future Ideas
programmatic Queue management could be possible using a mechanism like
"#{rich:component('queueId')}"
with possible methods on the object as below:
getQueueSize()
getEvents()
clear()
removeEvent(i)
Event.getSource()
OPEN ITEM: what other methods would be useful?