/** * Override handleRequest in order to perform processing specific to this component. * * @param request the request being responded to. */ @Override public void handleRequest(final Request request) { super.handleRequest(request); // Check if window in request boolean targeted = isPresent(request); setTargeted(targeted); if (getState() == ACTIVE_STATE && isTargeted()) { getComponentModel().wrappedContent.serviceRequest(request); } }
@Test public void testIsAjaxTargeted() { WApplication app = new WApplication(); WPanel appPanel = new WPanel(); WDialog dialog = new WDialog(); WPanel dialogPanel = new WPanel(); app.add(appPanel); app.add(dialog); dialog.setContent(dialogPanel); app.setLocked(true); UIContext uic = createUIContext(); uic.setUI(app); setActiveContext(uic); dialog.display(); app.serviceRequest(new MockRequest()); Assert.assertFalse("Should not be targeted if there is no AJAX operation", dialog. isAjaxTargeted()); setActiveAjaxOperation(appPanel); Assert.assertFalse("Should not be targeted if targeting another component", dialog. isAjaxTargeted()); setActiveAjaxOperation(dialog); Assert.assertTrue("Should be targeted when targeted directly", dialog.isAjaxTargeted()); setActiveAjaxOperation(dialogPanel); Assert.assertTrue("Should be targeted when a child component is targeted", dialog. isAjaxTargeted()); }