/** * 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; }
for (String targetId : operation.getTargets()) { ComponentWithContext target; if (targetId.equals(operation.getTriggerId())) {
for (String targetId : operation.getTargets()) { ComponentWithContext target; if (targetId.equals(operation.getTriggerId())) {
xml.appendTag("ui:debug"); for (String targetId : operation.getTargets()) { ComponentWithContext target = WebUtilities.getComponentById(targetId, true); if (target != null) {
@Test public void testPreparePaintComponent() { WApplication app = new WApplication(); AjaxTrigger trigger = new WButton(); AjaxTarget target = new WPanel(); WAjaxControl control = new WAjaxControl(trigger, target); app.add(control); app.add(trigger); app.add(target); app.setLocked(true); UIContext uic = createUIContext(); uic.setUI(app); setActiveContext(uic); MockRequest req = new MockRequest(); control.handleRequest(req); control.preparePaint(req); AjaxOperation ajaxOperation = AjaxHelper.getAjaxOperation(trigger.getId()); Assert.assertNotNull("Ajax operation should have been registered", ajaxOperation); Assert.assertEquals("Incorrect ajax operation trigger id", trigger.getId(), ajaxOperation. getTriggerId()); Assert.assertEquals("Incorrect ajax operation targets", target.getId(), ajaxOperation. getTargets().get(0)); }