Package org.openfaces.util

Examples of org.openfaces.util.ScriptBuilder


        Object viewStructureId = stateIdxHolder.getViewStructureId();
        if (viewStructureId == null) {
            return;
        }

        ScriptBuilder scriptBuilder = new ScriptBuilder();
        final List<UIForm> uiForms = stateIdxHolder.getForms();
        if (uiForms.isEmpty()) {
            scriptBuilder.append(writeViewStateScripts(viewStructureId, ""));
        } else {
            for (UIForm form : uiForms) {
                String formId = form.getId();
                scriptBuilder.append(writeViewStateScripts(viewStructureId, formId));
            }
        }

        if (simpleUpdate != null) {
            List<AjaxPortionData> tempList = new ArrayList<AjaxPortionData>();
            for (AjaxPortionData portionData : simpleUpdate) {
                tempList.add(formatJs(scriptBuilder.toString(), portionData));
            }
            simpleUpdate = tempList;
        } else if (portions != null && !portions.isEmpty()) {
            AjaxPortionData portionData = portions.get(0);
            portions.set(0, formatJs(scriptBuilder.toString(), portionData));
        }
    }
View Full Code Here


            portions.set(0, formatJs(scriptBuilder.toString(), portionData));
        }
    }

    private ScriptBuilder writeViewStateScripts(Object viewStructureId, String formId) {
        ScriptBuilder scriptBuilder = new ScriptBuilder();
        final boolean isNotEmptyForm = formId != null && formId.length() > 0;

        if (stateIdxHolder.getViewStateIdentifier() != null) {
            scriptBuilder.append("O$.updateViewId('").append(stateIdxHolder.getViewStateIdentifier()).append("'");
            if (isNotEmptyForm) {
                scriptBuilder.append(",'").append(formId).append("'");
            }
            scriptBuilder.append(");");
        } else {
            if (Environment.isRI()) {
                scriptBuilder.append("O$.updateViewId('").append(viewStructureId).append("'");
                if (isNotEmptyForm) {
                    scriptBuilder.append(",'").append(formId).append("'");
                }
                scriptBuilder.append(");");
            } else {
                scriptBuilder.append("");
            }
        }

        return scriptBuilder;
    }
View Full Code Here

                    cancelButton.setStyle(dialog.getCancelButtonStyle());
                    cancelButton.setStyleClass(dialog.getCancelButtonClass());
                    cancelButton.encodeAll(context);
                    writer.endElement("div");

                    Rendering.renderInitScript(context, new ScriptBuilder().functionCall("O$.Timetable._initEventEditorDialog",
                            timetableView,
                            dialog,
                            dialog.getCreateEventCaption(),
                            dialog.getEditEventCaption(),
                            dialog.isCentered()).semicolon());
View Full Code Here

    }

    @Override
    protected void encodeScriptsAndStyles(FacesContext context, PopupLayer component) throws IOException {
        super.encodeScriptsAndStyles(context, component);
        Rendering.renderInitScript(context, new ScriptBuilder().functionCall("O$.fixInputsWidthStrict",
                new FunctionCallScript("O$", component)));

    }
View Full Code Here

    @Override
    protected void encodeScriptsAndStyles(FacesContext context, PopupLayer component) throws IOException {
        super.encodeScriptsAndStyles(context, component);

        AbstractWindow win = (AbstractWindow) component;
        ScriptBuilder sb = new ScriptBuilder();
        sb.initScript(context, win, "O$.Window._init",
                win.isResizable(),
                win.isDraggableByContent(),
                win.getMinWidth(),
                win.getMinHeight());
        Rendering.renderInitScript(context, sb, getWindowJs(context));
View Full Code Here

            String containerClass,
            List<SubPanel> allItems
    ) throws IOException {
        LoadingMode loadingMode = layeredPane.getLoadingMode();

        ScriptBuilder sb = new ScriptBuilder();
        sb.initScript(context, layeredPane, "O$.LayeredPane._init",
                Rendering.getRolloverClass(context, layeredPane),
                containerClass,
                loadingMode,
                allItems.size(),
                layeredPane.getSelectedIndex());
View Full Code Here

    protected void renderInitScript(FacesContext facesContext, SelectBooleanCheckbox checkbox,
                                    JSONObject imagesObj, JSONObject stylesObj,
                                    AnonymousFunction onchangeFunction, boolean triStateAllowed) throws IOException {
        Iterable<String> stateList = getStateList(checkbox, triStateAllowed);
        Script initScript = new ScriptBuilder().initScript(facesContext, checkbox, "O$.Checkbox._init",
                imagesObj,
                stylesObj,
                stateList,

                checkbox.isDisabled(),
View Full Code Here

    protected void renderInitScript(FacesContext facesContext, OUISelectManyInputBase selectManyInputBase,
                                    JSONObject imagesObj, JSONObject stylesObj,
                                    int selectItemCount, AnonymousFunction onchangeFunction)
            throws IOException {
        SelectManyCheckbox selectManyCheckbox = (SelectManyCheckbox) selectManyInputBase;
        Script initScript = new ScriptBuilder().initScript(facesContext, selectManyCheckbox, "O$.ManyCheckbox._init",
                imagesObj,
                stylesObj,
                selectItemCount,
                selectManyCheckbox.isDisabled(),
                selectManyCheckbox.isReadonly(),
View Full Code Here

        Rendering.renderHiddenField(writer, clientId + LEFT_HIDDEN_FIELD_SUFFIX, popup.getLeft());
        Rendering.renderHiddenField(writer, clientId + TOP_HIDDEN_FIELD_SUFFIX, popup.getTop());
//    Rendering.renderHiddenField(writer, clientId + ANCHOR_HIDDEN_FIELD_SUFFIX, popupInvokerId);

        if (popup.getHideOnOuterClick()) {
            ScriptBuilder buf = new ScriptBuilder();
            buf.functionCall("O$.Popup._init", clientId).semicolon();
            Rendering.renderInitScript(context, buf,
                    Resources.utilJsURL(context),
                    Resources.internalURL(context, "popup.js"));
        }

        ScriptBuilder sb = new ScriptBuilder();
        String width = popup.getWidth();
        if (width == null && popup.getAutosizing() != Autosizing.ON)
            width = getDefaultWidth();
        String height = popup.getHeight();
        if (height == null && popup.getAutosizing() != Autosizing.ON)
            height = getDefaultHeight();
        String modalLayerClass = popup.isModal() ? Styles.getCSSClass(context,
                popup, popup.getModalLayerStyle(),
                getDefaultModalLayerClass(),
                popup.getModalLayerClass()) : null;

        sb.initScript(context, popup, "O$.PopupLayer._init",
                popup.getLeft(),
                popup.getTop(),
                width,
                height,
                Rendering.getRolloverClass(context, popup),
                popup.getHidingTimeout(),
                popup.getDraggable(),
                popup.getAutosizing(),
                modalLayerClass,
                popup.getHideOnEsc(),
                Environment.isAjax4jsfRequest(),
                popup.getContainment(),
                popup.getContainmentRole());

        String onShow = popup.getOnshow();
        if (onShow != null) {
            sb.append("\nO$('").append(clientId).append("').onshow = function (event) {"); // todo: refactor passing events into passing them as a single JSON param to the initialization function
            sb.append(onShow);
            sb.append("};");
        }

        String onHide = popup.getOnhide();
        if (onHide != null) {
            sb.append("\nO$('").append(clientId).append("').onhide = function (event) {");
            sb.append(onHide);
            sb.append("};");
        }

        String ondragstart = popup.getOndragstart();
        if (ondragstart != null) {
            sb.append("\nO$('").append(clientId).append("').ondragstart = function (event) {");
            sb.append(ondragstart);
            sb.append("};");
        }

        String ondragend = popup.getOndragend();
        if (ondragend != null) {
            sb.append("\nO$('").append(clientId).append("').ondragend = function (event) {");
            sb.append(ondragend);
            sb.append("};");
        }

        if (popupInvokerId != null) {
            sb.append("\nO$('");
            sb.append(clientId);
            sb.append("').attachToElement(O$('").append(popupInvokerId).append("'), ");
            sb.append(nullOrJsString(popup.getAnchorX()));
            sb.append(", ");
            sb.append(nullOrJsString(popup.getAnchorY()));
            sb.append(");");
        }

        Rendering.renderInitScript(context, sb,
                Resources.utilJsURL(context),
                Resources.internalURL(context, "window/popupLayer.js"));
View Full Code Here

            if (ve == null || ve.isReadOnly(elContext))
                autoSaveState = false;
        }


        ScriptBuilder buf = new ScriptBuilder().initScript(context, table, "O$.Table._initColumnResizing",
                columnResizing.getRetainTableWidth(),
                columnResizing.getMinColWidth(),
                columnResizing.getResizeHandleWidth(),
                columnParams,
                autoSaveState);
View Full Code Here

TOP

Related Classes of org.openfaces.util.ScriptBuilder

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.