Package org.richfaces.component

Examples of org.richfaces.component.UIScripts


    private JavaScriptServiceImpl serviceImpl;

    @Before
    public void setUpResource() {
        serviceImpl = new JavaScriptServiceImpl();
        scriptResource = new UIScripts();
    }
View Full Code Here


    private static final String SCRIPT = "script";
    private static final ResourceKey JQUERY = ResourceKey.create("jquery.js", "org.richfaces");

    @Override
    public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
        UIScripts validatorScript = (UIScripts) component;
        ResponseWriter responseWriter = context.getResponseWriter();
        // TODO - change behavior for AJAX requests.
        Collection<Object> scripts = validatorScript.getScripts();
        encodeDependentResources(context, component, scripts);
        Collection<Object> pageReadyScripts = validatorScript.getPageReadyScripts();
        if (!pageReadyScripts.isEmpty()) {
            encodeResource(component, context, JQUERY);
            encodeDependentResources(context, component, pageReadyScripts);
        }
        responseWriter.startElement(SCRIPT, null);
View Full Code Here

     * (non-Javadoc)
     *
     * @see org.richfaces.javascript.JavaScriptService#addScript(org.richfaces.javascript.ScriptString)
     */
    public <S> S addScript(FacesContext facesContext, S script) {
        UIScripts scriptResource = getOrCreateScriptResource(facesContext);

        return addOrFind(scriptResource.getScripts(), script);
    }
View Full Code Here

     * (non-Javadoc)
     *
     * @see org.richfaces.javascript.JavaScriptService#addPageReadyScript(org.richfaces.javascript.ScriptString)
     */
    public <S> S addPageReadyScript(FacesContext facesContext, S script) {
        UIScripts scriptResource = getOrCreateScriptResource(facesContext);

        return addOrFind(scriptResource.getPageReadyScripts(), script);
    }
View Full Code Here

    UIScripts getOrCreateScriptResource(FacesContext facesContext) {
        UIViewRoot viewRoot = facesContext.getViewRoot();
        if (null == viewRoot) {
            throw new FacesException("View is not created");
        }
        UIScripts scriptResource = findScriptResource(facesContext, viewRoot);
        if (null == scriptResource) {
            scriptResource = (UIScripts) facesContext.getApplication().createComponent(UIScripts.COMPONENT_TYPE);
            viewRoot.addComponentResource(facesContext, scriptResource);
        }
        return scriptResource;
View Full Code Here

        return scriptResource;
    }

    private UIScripts findScriptResource(FacesContext facesContext, UIViewRoot viewRoot) {
        List<UIComponent> componentResources = viewRoot.getComponentResources(facesContext, "form");
        UIScripts scriptResource = findScriptComponent(componentResources);
        if (null == scriptResource) {
            componentResources = viewRoot.getComponentResources(facesContext, "body");
            scriptResource = findScriptComponent(componentResources);
        }
        return scriptResource;
View Full Code Here

    }

    private UIScripts findScriptComponent(List<UIComponent> componentResources) {
        for (UIComponent uiComponent : componentResources) {
            if (uiComponent instanceof UIScripts) {
                UIScripts script = (UIScripts) uiComponent;
                return script;
            }
        }
        return null;
    }
View Full Code Here

            @Override
            UIScripts getOrCreateScriptResource(FacesContext facesContext) {
                return scriptResource;
            }
        };
        scriptResource = new UIScripts();
    }
View Full Code Here

TOP

Related Classes of org.richfaces.component.UIScripts

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.