/** * Indicates whether the dialog is currently the target of an AJAX operation. * * @return true if the dialog is currently AJAX targeted, otherwise false. */ public final boolean isAjaxTargeted() { // If the AJAX target is within the dialog, it should be visible. AjaxOperation operation = AjaxHelper.getCurrentOperation(); if (operation == null) { return false; } String dialogId = getId(); String containerId = operation.getTargetContainerId(); if (containerId != null && containerId.startsWith(dialogId)) { // target is the dialog, or somewhere within the dialog return true; } if (operation.getTargets() != null && UIContextHolder.getCurrent() != null) { for (String targetId : operation.getTargets()) { if (targetId.startsWith(dialogId)) { return true; } } } return false; }
/** * Paints the targeted ajax regions. The format of the response is an agreement between the server and the client * side JavaScript handling our ajax response. * * @param renderContext the renderContext to send the output to. */ @Override public void paint(final RenderContext renderContext) { AjaxOperation operation = AjaxHelper.getCurrentOperation(); if (operation == null) { // the request attribute that we place in the ui context in the action phase can't be null throw new SystemException( "Can't paint AJAX response. Couldn't find the expected reference to the AjaxOperation."); } if (operation.getTargetContainerId() != null) { paintContainerResponse(renderContext, operation); } else { paintResponse(renderContext, operation); } }
if (operation.getTargetContainerId() != null || operation.isInternalAjaxRequest()) { return true;
xml.appendAttribute("id", operation.getTargetContainerId()); xml.appendAttribute("action", AjaxOperation.AjaxAction.REPLACE_CONTENT.getDesc()); xml.appendClose();