Package org.richfaces.focus

Examples of org.richfaces.focus.FocusManager


        factory.setInstance(MappedResourceFactory.class, new MappedResourceFactoryImpl());
//        factory.setInstance(FocusManager.class, ServiceLoader.loadService(FocusManager.class, FocusManagerImpl.class));
        factory.setInstance(ResourceMappingConfiguration.class, new ResourceMappingConfiguration());

        // workaround for loading service from richfaces module (needs to be bypassed during tests)
        FocusManager focusManager = ServiceLoader.loadService(FocusManager.class);
        if (focusManager == null) {
            LOG.warn("There was no service " + FocusManager.class.getName() + " found");
        } else {
            factory.setInstance(FocusManager.class, focusManager);
        }
View Full Code Here


@RequestScoped
@ManagedBean
public class FocusManagerBean {

    public void preRenderView() {
        FocusManager focusManager = ServiceTracker.getService(FocusManager.class);
        focusManager.focus("input2");
    }
View Full Code Here

    @Override
    public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
        if (event instanceof PreRenderViewEvent) {
            FacesContext context = FacesContext.getCurrentInstance();
            FocusManager focusManager = ServiceTracker.getService(context, FocusManager.class);
            focusManager.focus(enforceFocusId);
        }
    }
View Full Code Here

    }

    @Test
    public void test() {
        // having
        FocusManager focusManager = new FocusManagerImpl();

        // when
        focusManager.focus(null);

        // then
        verify(attributes).put(FocusManager.FOCUS_CONTEXT_ATTRIBUTE, null);
        assertFalse(FocusRendererUtils.isFocusEnforced(facesContext));
View Full Code Here

    }

    @Test
    public void test2() {
        // having
        FocusManager focusManager = new FocusManagerImpl();
        String componentId = "someComponentId";
        String clientId = "someClientId";

        when(component.getClientId(facesContext)).thenReturn(clientId);
        when(viewRoot.findComponent(componentId)).thenReturn(component);

        // when
        focusManager.focus(componentId);

        // then
        // verify(attributes).put(FocusManager.FOCUS_CONTEXT_ATTRIBUTE, clientId);
        assertEquals(clientId, attributes.get(FocusManager.FOCUS_CONTEXT_ATTRIBUTE));
        assertTrue(attributes.containsKey(FocusManager.FOCUS_CONTEXT_ATTRIBUTE));
View Full Code Here

TOP

Related Classes of org.richfaces.focus.FocusManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.