/** * {@inheritDoc} */ @Override public WComponent getFocussed() { return backing.getFocussed(); }
/** * Sets the focus back to this button unless explicity set elsewhere. */ protected void focusMe() { if (UIContextHolder.getCurrent().getFocussed() == null) { setFocussed(); } }
@Override public void run() { getActionOnChange().execute(event); if (isCAT && UIContextHolder.getCurrent().getFocussed() == null) { setFocussed(); } } };
@Test public void testFocussedAccessors() { UIContext uic = createUIContext(); WComponent component = new DefaultWComponent(); uic.setFocussed(component); uic.setUI(component); Assert.assertEquals("Incorrect focussed component returned", component, uic.getFocussed()); UIContext uic2 = createUIContext(); uic2.setUI(component); uic.setFocussed(component, uic2); Assert.assertEquals("Incorrect focussed component returned with a different context", component, uic.getFocussed()); }
/** * Test setFocus - on itself. */ @Test public void testSetFocussed() { AbstractWComponent comp = new SimpleComponent(); comp.setLocked(true); UIContext uic = createUIContext(); setActiveContext(uic); comp.setFocussed(); Assert.assertEquals("comp itself should have the focus", comp, uic.getFocussed()); }
@Test public void testSetFoccussed() { RadioButtonGroup group = new RadioButtonGroup(); setActiveContext(createUIContext()); group.setFocussed(); Assert.assertNull("Foccussed should be null for a radio button group", UIContextHolder. getCurrent() .getFocussed()); }
if (TabMode.SERVER.equals(tab.getMode()) && UIContextHolder.getCurrent().getFocussed() == null) { tab.setFocussed();
/** * Perform change logic for this component. * <p>Reset focus ONLY if the current Request is an Ajax request. See https://github.com/BorderTech/wcomponents/issues/501.</p> */ protected void doHandleChanged() { // If there is an associated action, execute it if (getActionOnChange() != null) { final ActionEvent event = new ActionEvent(this, getActionCommand(), getActionObject()); final boolean isCAT = isCurrentAjaxTrigger(); Runnable later = new Runnable() { @Override public void run() { getActionOnChange().execute(event); if (isCAT && UIContextHolder.getCurrent().getFocussed() == null) { setFocussed(); } } }; invokeLater(later); } else if (AjaxHelper.isCurrentAjaxTrigger(this) && UIContextHolder.getCurrent().getFocussed() == null) { setFocussed(); } }
if (changed && (UIContextHolder.getCurrent() != null) && (UIContextHolder.getCurrent().getFocussed() == null) && currentGroup.isCurrentAjaxTrigger()) { setFocussed();