Package org.richfaces.javascript

Examples of org.richfaces.javascript.JavaScriptService


    @Override
    protected void preEncodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
        ScriptString script = prepareCSVMessageScript(facesContext);

        JavaScriptService jsService = ServiceTracker.getService(JavaScriptService.class);
        jsService.addScript(facesContext, script);
    }
View Full Code Here


    protected String getJSClassName() {
        return "RichFaces.ui.Message";
    }

    protected void encodeScript(FacesContext facesContext, UIComponent component) throws IOException {
        JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
        JSFunction messageObject = new JSObject(getJSClassName(), component.getClientId(facesContext));
        Map<String, Object> attributes = component.getAttributes();
        Builder<String, Object> parametersBuilder = ImmutableMap.builder();
        String forId = (String) attributes.get("for");
        RendererUtils rendererUtils = RendererUtils.getInstance();
        if (!Strings.isNullOrEmpty(forId)) {
            UIComponent target = rendererUtils.findComponentFor(component, forId);
            if (null != target) {
                parametersBuilder.put("forComponentId", target.getClientId(facesContext));
            }
        }
        Severity level = getLevel(component);
        if (FacesMessage.SEVERITY_INFO != level) {
            parametersBuilder.put("level", level.getOrdinal());
        }
        if (!rendererUtils.isBooleanAttribute(component, "showSummary")) {
            parametersBuilder.put("showSummary", false);
        }
        if (rendererUtils.isBooleanAttribute(component, "showDetail")) {
            parametersBuilder.put("showDetail", true);
        }
        if (rendererUtils.isBooleanAttribute(component, "tooltip")) {
            parametersBuilder.put("tooltip", true);
        }
        if (isComponentMessages(component) && rendererUtils.isBooleanAttribute(component, "globalOnly")) {
            parametersBuilder.put("globalOnly", true);
        }
        if (isComponentMessages(component)) {
            parametersBuilder.put("isMessages", true);
        }
        messageObject.addParameter(parametersBuilder.build());
        // RendererUtils.getInstance().writeScript(facesContext, component, messageObject);
        javaScriptService.addPageReadyScript(facesContext, messageObject);
    }
View Full Code Here

     */
    String buildAndStoreValidatorScript(ClientBehaviorContext behaviorContext, ClientValidatorBehavior behavior) {
        ComponentValidatorScript validatorScript = createValidatorScript(behaviorContext, behavior);
        if (null != validatorScript) {
            FacesContext facesContext = behaviorContext.getFacesContext();
            JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
            validatorScript = javaScriptService.addScript(facesContext, validatorScript);
            return validatorScript.createCallScript(behaviorContext.getComponent().getClientId(facesContext),
                    behaviorContext.getSourceId());
        } else {
            return null;
        }
View Full Code Here

        javaScriptService.addPageReadyScript(facesContext, messageObject);
    }

    protected void encodeNotification(FacesContext facesContext, UIComponent component, Map<String, Object> options)
            throws IOException {
        JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
        for (MessageForRender message : getVisibleMessages(facesContext, component)) {
            JSFunction notifyCall = new JSFunction("RichFaces.ui.Notify");
            Map<String, Object> optionsCopy = new LinkedHashMap<String, Object>(options);
            addMessageSpecificAttributes(message, facesContext, component, optionsCopy);
            notifyCall.addParameter(optionsCopy);
            javaScriptService.addPageReadyScript(facesContext, notifyCall);
            message.rendered();
        }
    }
View Full Code Here

    /**
     * This method ensures that component which should be focused will be present in the page in the time of running script (oncomplete).
     */
    public void renderOncompleteScript(FacesContext context, String script) {
        JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
        javaScriptService.addScript(context, new JSLiteral(script));
    }
View Full Code Here

        Object script = getScriptObject(context, component);
        if (script == null) {
            return;
        }

        JavaScriptService service = ServiceTracker.getService(JavaScriptService.class);
        service.addScript(context, script);
    }
View Full Code Here

     */
    protected void addOnCompleteParam(FacesContext context, String itemName, String panelId) {
        String script = new StringBuilder().append("RichFaces.component('").append(panelId).append("').onCompleteHandler('")
                .append(itemName).append("');").toString();

        JavaScriptService scriptService = ServiceTracker.getService(JavaScriptService.class);
        scriptService.addScript(context, new JSLiteral(script.toString()));
    }
View Full Code Here

            UIComponent component = event.getComponent();
            if (component instanceof EditableValueHolder) {
                String clientId = component.getClientId(facesContext);
                final ImmutableList<Message> messages = ImmutableList.copyOf(Iterators.transform(facesContext.getMessages(clientId), MESSAGES_TRANSFORMER));

                JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
                javaScriptService.addPageReadyScript(facesContext, new MessageUpdateScript(clientId, messages));

                if (messages.isEmpty()) {
                    final String onvalid = getOnvalid();
                    if (onvalid != null && !"".equals(onvalid.trim())) {
                        javaScriptService.addPageReadyScript(facesContext, new AnonymousFunctionCall().addToBody(onvalid));
                    }
                } else {
                    final String oninvalid = getOninvalid();
                    if (oninvalid != null && !"".equals(oninvalid.trim())) {
                        javaScriptService.addPageReadyScript(facesContext, new AnonymousFunctionCall("messages").addParameterValue(ScriptUtils.toScript(messages)).addToBody(oninvalid));
                    }
                }
            }
        }
        super.broadcast(event);
View Full Code Here

        Object script = getScriptObject(context, component);
        if (script == null) {
            return;
        }

        JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
        javaScriptService.addScript(context, script);
    }
View Full Code Here

        return "RichFaces.ui.NotifyMessage";
    }

    protected void encodeScript(FacesContext facesContext, UIComponent component, Map<String, Object> options)
            throws IOException {
        JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
        JSFunction messageObject = new JSObject(getJSClassName(), component.getClientId(facesContext));
        Map<String, Object> attributes = component.getAttributes();
        Builder<String, Object> parametersBuilder = ImmutableMap.builder();
        String forId = (String) attributes.get("for");
        RendererUtils rendererUtils = RendererUtils.getInstance();
        if (!Strings.isNullOrEmpty(forId)) {
            UIComponent target = rendererUtils.findComponentFor(component, forId);
            if (null != target) {
                parametersBuilder.put("forComponentId", target.getClientId(facesContext));
            }
        }
        Severity level = getLevel(component);
        if (FacesMessage.SEVERITY_INFO != level) {
            parametersBuilder.put("level", level.getOrdinal());
        }
        if (!rendererUtils.isBooleanAttribute(component, "showSummary")) {
            parametersBuilder.put("showSummary", false);
        }
        if (rendererUtils.isBooleanAttribute(component, "showDetail")) {
            parametersBuilder.put("showDetail", true);
        }
        if (rendererUtils.isBooleanAttribute(component, "tooltip")) {
            parametersBuilder.put("tooltip", true);
        }
        if (isComponentMessages(component) && rendererUtils.isBooleanAttribute(component, "globalOnly")) {
            parametersBuilder.put("globalOnly", true);
        }
        if (isComponentMessages(component)) {
            parametersBuilder.put("isMessages", true);
        }
        messageObject.addParameter(parametersBuilder.build());
        messageObject.addParameter(options);
        // RendererUtils.getInstance().writeScript(facesContext, component, messageObject);
        javaScriptService.addPageReadyScript(facesContext, messageObject);
    }
View Full Code Here

TOP

Related Classes of org.richfaces.javascript.JavaScriptService

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.