Package org.richfaces.component

Examples of org.richfaces.component.AbstractFocus


        }).inspect(new AbstractComponentAssertion() {
            private static final long serialVersionUID = 1L;

            @AfterPhase(Phase.RENDER_RESPONSE)
            public void verify_default_attributes() {
                AbstractFocus component = bean.getComponent();
                assertTrue("Component is ajaxRenderer='true' by default", component.isAjaxRendered());
                assertTrue("Component is validationAware='true' by default", component.isValidationAware());
                assertFalse("Component is preserve='false' by default", component.isPreserve());
                assertFalse("Component is delayed='false' by default", component.isDelayed());
            }
        });
    }
View Full Code Here


            @AfterPhase(Phase.RENDER_RESPONSE)
            public void verifyGlobalMessageIsIgnored() {
                FacesContext context = FacesContext.getCurrentInstance();

                AbstractFocus component = bean.getComponent();
                FocusRendererBase renderer = bean.getRenderer();
                String candidates = renderer.getFocusCandidatesAsString(context, component);

                assertEquals("form", candidates);
            }
View Full Code Here

    protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component)
            throws IOException {
        if (!(component instanceof AbstractFocus)) {
            return;
        }
        AbstractFocus uiFocus = (AbstractFocus) component;
        final String clientId = getUtils().clientId(context, component);
        checkValidity(context, uiFocus);
        Integer priority = uiFocus.getPriority();
        String targetClientId = uiFocus.getTargetClientId();
        if (targetClientId == null || "".equals(targetClientId)) {
            String targetComponentId = uiFocus.getTargetComponentId(context);
            String suffix = uiFocus.getSuffix();
            if (targetComponentId == null || "".equals(targetComponentId)) {
                return;
            }
            UIComponent forcomp = getUtils().findComponentFor(component, targetComponentId);
            if (forcomp == null) {
                throw new FacesException("No component with id=" + targetComponentId + " found!");
            }
            targetClientId = forcomp.getClientId(context);
            AbstractFocusModifier modifier = AbstractFocus.findModifier(forcomp);
            if (modifier != null) {
                final String modifiedTargetClientId = modifier.getTargetClientId();
                if (modifiedTargetClientId != null && !modifiedTargetClientId.equals("")) {
                    targetClientId = modifiedTargetClientId;
                } else {
                    suffix = modifier.getSuffix();
                }
            }
            if (priority == null) {
                priority = uiFocus.calculatePriority(forcomp);
            }
            if (suffix != null && !"".equals(suffix)) {
                targetClientId += suffix;
            }
        }
        if (targetClientId == null || targetClientId.equals("")) {
            return;
        }
        if (priority == null) {
            priority = AbstractFocus.DEFAULT_PRIORITY;
        }
        writer.startElement(HtmlConstants.SCRIPT_ELEM, null);
        writer.writeAttribute(HtmlConstants.TYPE_ATTR, "text/javascript", "type");
        writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, clientId, HtmlConstants.ID_ATTRIBUTE);
        if (AbstractFocus.TIMING_ON_LOAD.equals(uiFocus.getTiming())) {
            writer.write(new JSFunction("RichFaces.ui.Focus.setFocus", targetClientId, priority).toScript());
            writer.write(";");
        } else {
            writer.write(new JSFunction("RichFaces.ui.Focus.setFocus", targetClientId, priority, clientId,
                    uiFocus.getTiming()).toScript());
            writer.write(";");
        }
        if (uiFocus.getName() != null && !uiFocus.getName().trim().equals("")) {
            final JSFunctionDefinition definition = new JSFunctionDefinition().addToBody(new JSFunction("RichFaces.ui.Focus.focusStored", clientId));
            definition.setName(uiFocus.getName());
            writer.write(definition.toScript());
            writer.write(";");
        }
        writer.endElement(HtmlConstants.SCRIPT_ELEM);
    }
View Full Code Here

    @AfterPhase(Phase.RENDER_RESPONSE)
    public void verify_focus_candidates() {

        FacesContext context = FacesContext.getCurrentInstance();

        AbstractFocus component = bean.getComponent();
        FocusRendererBase renderer = bean.getRenderer();

        String actualFocusCandidates = renderer.getFocusCandidatesAsString(context, component);

        assertEquals(message, expectedFocusCandidates, actualFocusCandidates);
View Full Code Here

            @AfterPhase(Phase.RENDER_RESPONSE)
            public void verifyGlobalMessageIsIgnored() {
                FacesContext context = FacesContext.getCurrentInstance();

                AbstractFocus component = bean.getComponent();
                FocusRendererBase renderer = bean.getRenderer();
                String candidates = renderer.getFocusCandidatesAsString(context, component);

                assertEquals("form", candidates);
            }
View Full Code Here

        }).inspect(new AbstractComponentAssertion() {
            private static final long serialVersionUID = 1L;

            @AfterPhase(Phase.RENDER_RESPONSE)
            public void verify_default_attributes() {
                AbstractFocus component = bean.getComponent();
                assertTrue("Component is ajaxRenderer='true' by default", component.isAjaxRendered());
                assertTrue("Component is validationAware='true' by default", component.isValidationAware());
                assertFalse("Component is preserve='false' by default", component.isPreserve());
                assertFalse("Component is delayed='false' by default", component.isDelayed());
            }
        });
    }
View Full Code Here

    @AfterPhase(Phase.RENDER_RESPONSE)
    public void verify_focus_is_not_applied() {
        FacesContext context = FacesContext.getCurrentInstance();

        AbstractFocus component = bean.getComponent();
        FocusRendererBase renderer = bean.getRenderer();
        assertFalse(renderer.shouldApply(context, component));
    }
View Full Code Here

TOP

Related Classes of org.richfaces.component.AbstractFocus

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.