use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class AjaxInterceptor method isProcessTriggerOnly.
/**
* Check if process this trigger only.
*
* @param triggerWithContext the trigger with its context
* @param operation current ajax operation
* @return true if process this trigger only
*/
private boolean isProcessTriggerOnly(final ComponentWithContext triggerWithContext, final AjaxOperation operation) {
// Target container implies only process the trigger or is Internal Ajax
if (operation.getTargetContainerId() != null || operation.isInternalAjaxRequest()) {
return true;
}
WComponent trigger = triggerWithContext.getComponent();
// Check if trigger is a polling AJAX control
if (trigger instanceof WAjaxControl) {
// Get user context
UIContext uic = triggerWithContext.getContext();
UIContextHolder.pushContext(uic);
try {
WAjaxControl ajax = (WAjaxControl) trigger;
// Is a polling region so only process trigger
if (ajax.getDelay() > 0) {
return true;
}
} finally {
UIContextHolder.popContext();
}
}
return false;
}
use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class WAjaxControlRenderer method doRender.
/**
* Paints the given AjaxControl.
*
* @param component the AjaxControl to paint
* @param renderContext the RenderContext to paint to
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WAjaxControl ajaxControl = (WAjaxControl) component;
XmlStringBuilder xml = renderContext.getWriter();
WComponent trigger = ajaxControl.getTrigger() == null ? ajaxControl : ajaxControl.getTrigger();
int delay = ajaxControl.getDelay();
if (ajaxControl.getTargets() == null || ajaxControl.getTargets().isEmpty()) {
return;
}
// Start tag
xml.appendTagOpen("ui:ajaxtrigger");
xml.appendAttribute("triggerId", trigger.getId());
xml.appendOptionalAttribute("loadOnce", ajaxControl.isLoadOnce(), "true");
xml.appendOptionalAttribute("delay", delay > 0, delay);
xml.appendClose();
// Targets
for (AjaxTarget target : ajaxControl.getTargets()) {
xml.appendTagOpen("ui:ajaxtargetid");
xml.appendAttribute("targetId", target.getId());
xml.appendEnd();
}
// End tag
xml.appendEndTag("ui:ajaxtrigger");
}
Aggregations