Using ajax in widgets
When using dynaWidgets you do not want to reload the whole page on every request, especially on updating the widget´s contents. The following practices shows how to use ajax in combination with dynaWidgets.Ajax Status Indicator
Whenever ajax is processed from within a widget the ajax status indicator in the widget header will be shown until the action is finished:
Ajax Loading of widget content
The initial loading of the widget contents can be proceeded in parallel by using ajax. Therefore the dynaWidget grid must be configured like this:
<dwComp:dynaWidgetGrid id="myGrid" columns="2"
...
loadWidgetsByAjax="true"
... />
What´s important here:
- widgets may not have their own forms in the content facelets, there must be one form around the dynaWidget grid component
- on sending an ajax action from a widget, only the input components of the widget content facelet will be decoded, not those from other widgets
- the widget content is also reloaded by ajax if you use the widget´s reload action
Processing ajax actions from within a widget
For using ajax in widget contents there are special ajax action components:
ajaxWidget_view.xhtml:
...
<dwComp:widgetAjaxLink
value="do some ajax action"
reRenderWidget="true"
actionBean="#{myWidgetActionBean}"
actionName="myAction" />
...
What´s important here:
- using the widget ajax components, the ajax action will be connected to the widgets ajax status (indicator)
- each widget has an ajax queue to synchronize multiple ajax calls from within a widget. using the widget ajax components, the action is bound to this ajax queue
- you can also use standard a4j actions. To connect those to the widgets queue and status you have to link it to the by using eventsQueue="#{dwFct:widgetAjaxQueueName()}".
An example for using ajax in a widget
For details on using the ajax action components see content components.

