Package org.openfaces.org.json

Examples of org.openfaces.org.json.JSONArray


    public static JSONArray arrayToJSONArray(ConvertibleToJSON[] array, Map<String, TimeZone> params) {
        return listToJSONArray(Arrays.asList(array), params);
    }

    public static JSONArray listToJSONArray(List<? extends ConvertibleToJSON> entries, Map<String, TimeZone> params) {
        JSONArray eventsJsArray = new JSONArray();
        for (int i = 0; i < entries.size(); i++) {
            ConvertibleToJSON obj = entries.get(i);
            try {
                eventsJsArray.put(i, obj.toJSONObject(params));
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
        return eventsJsArray;
View Full Code Here


            writer.writeText(actionBar.getNoteText(), null);
        }
        writer.endElement("div");

        String userSpecifiedStyle = Styles.getCSSClass(context, actionBar, actionBar.getStyle(), actionBar.getStyleClass());
        JSONArray eventActions = getEventActions(context, actionBar);
        double actionRolloverBackgroundIntensity = actionBar.getActionRolloverBackgroundIntensity();
        double actionPressedBackgroundIntensity = actionBar.getActionPressedBackgroundIntensity();
        Rendering.renderInitScript(context, new ScriptBuilder().initScript(context, actionBar, "O$.Timetable._initEventActionBar",
                actionBar.getBackgroundIntensity(),
                userSpecifiedStyle,
View Full Code Here

        return result;
    }

    private JSONArray getEventActions(FacesContext context, EventActionBar actionBar) {
        List<EventAction> actionComponents = getEventActionComponents(context, actionBar);
        JSONArray result = new JSONArray();
        for (EventAction action : actionComponents) {
            try {
                JSONObject actionParams = action.toJSONObject(
                        Collections.singletonMap(EventActionBar.class, actionBar));
                result.put(result.length(), actionParams);
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
        return result;
View Full Code Here

    ) {
        int colCount = columns.size();
        List<BaseColumn>[] columnHierarchies = new List[colCount];
        TableHeaderOrFooter.composeColumnHierarchies(columns, columnHierarchies, true, false);

        JSONArray columnHierarchyArray;
        try {
            columnHierarchyArray = processColumnHierarchy(facesContext, columnHierarchies, 0, 0, colCount - 1);
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

    }

    private JSONArray processColumnHierarchy(
            FacesContext context, List<BaseColumn>[] columnHierarchies, int level, int startCol, int finishCol
    ) throws JSONException {
        JSONArray columnsArray = new JSONArray();
        int thisGroupStart = -1;
        BaseColumn thisGroup = null;
        for (int colIndex = startCol; colIndex <= finishCol + 1; colIndex++) {
            List<BaseColumn> thisColumnHierarchy = colIndex <= finishCol ? columnHierarchies[colIndex] : null;
            BaseColumn columnOrGroup = thisColumnHierarchy != null ? thisColumnHierarchy.get(level) : null;
            if (thisGroup == null) {
                thisGroup = columnOrGroup;
                thisGroupStart = startCol;
            } else if (columnOrGroup != thisGroup) {
                int thisGroupEnd = colIndex - 1;
                List<BaseColumn> lastColumnHierarchy = columnHierarchies[thisGroupEnd];

                JSONObject columnObj = getColumnParams(context, thisGroup, level);
                columnsArray.put(columnObj);
                boolean hasSubColumns = lastColumnHierarchy.size() - 1 > level;
                if (hasSubColumns) {
                    JSONArray subColumns = processColumnHierarchy(context, columnHierarchies, level + 1, thisGroupStart, thisGroupEnd);
                    columnObj.put("subColumns", subColumns);
                }
                thisGroup = columnOrGroup;
                thisGroupStart = colIndex;
            }
View Full Code Here

        else
            array.put(JSONObject.NULL);
    }

    private JSONArray getGridLineParams(TableStyles tableStyles, TableStyles defaultStyles) {
        JSONArray result = new JSONArray();
        addJSONEntry(result, getHorizontalGridLines(tableStyles, defaultStyles));
        addJSONEntry(result, getVerticalGridLines(tableStyles, defaultStyles));
        addJSONEntry(result, getCommonHeaderSeparator(tableStyles, defaultStyles));
        addJSONEntry(result, getCommonFooterSeparator(tableStyles, defaultStyles));
        addJSONEntry(result, getHeaderHorizSeparator(tableStyles, defaultStyles));
View Full Code Here

        }
        if (!isCommandComponent(parent)) {
            String ajaxComponentId = ajax.getId();
            script.append("if (!O$._renderIds) {O$._renderIds = []};O$._renderIds['").append(ajaxComponentId).append("'] = ");
            AjaxInitializer initializer = new AjaxInitializer();
            JSONArray idsArray = initializer.getRenderArray(context, ajax, ajax.getRender());
            script.append(idsArray);
            script.append(";");

            script.append("if (!O$._executeIds) {O$._executeIds = []};O$._executeIds['").append(ajaxComponentId).append("'] = ");
            JSONArray submittedIdsArray = initializer.getRenderArray(context, ajax, ajax.getExecute());
            if (!ajax.isStandalone() && ajax.getSubmitInvoker()) {
                String invokerId = OUIClientActionHelper.getClientActionInvoker(context, ajax);
                if (context.getViewRoot().findComponent(":" + invokerId) != null) {
                    // if invoker is a JSF component rather than raw HTML tag
                    submittedIdsArray.put(invokerId);
                }
            }
            script.append(submittedIdsArray);
            script.append(";");
View Full Code Here

        return itemsList;
    }

    private JSONArray getTabIds(FacesContext context, TabSet tabSet, List<Object> tabs) {
        JSONArray result = new JSONArray();

        String clientId = tabSet.getClientId(context);
        for (int tabIndex = 0, tabCount = tabs.size(); tabIndex < tabCount; tabIndex++) {
            Object tabObj = tabs.get(tabIndex);
            if (!isItemRendered(tabObj))
                continue;

            result.put(clientId + Rendering.CLIENT_ID_SUFFIX_SEPARATOR + tabIndex);
        }
        return result;
    }
View Full Code Here

                    ? timetableView.getTimeZone()
                    : TimeZone.getDefault();

            addedEvents = eventsFromJSONArray(timeZone, addedEventsArray);
            editedEvents = eventsFromJSONArray(timeZone, editedEventsObj);
            JSONArray removedEventIdsArray = JSONObject.NULL.equals(removedEventIdsObj) ? null : (JSONArray) removedEventIdsObj;
            int removedEventCount = removedEventIdsArray != null ? removedEventIdsArray.length() : 0;
            removedEventIds = new String[removedEventCount];
            for (int i = 0; i < removedEventCount; i++) {
                removedEventIds[i] = removedEventIdsArray.getString(i);
            }
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

    protected String getTimetableChangeEventKey(FacesContext context, TimetableView timetableView) {
        return "OF__TimetableChangeEvent for " + timetableView.getClientId(context);
    }

    protected TimetableEvent[] eventsFromJSONArray(TimeZone timeZone, Object arrayObj) throws JSONException {
        JSONArray array = JSONObject.NULL.equals(arrayObj) ? null : (JSONArray) arrayObj;
        int arrayLength = array != null ? array.length() : 0;
        TimetableEvent[] targetArray = new TimetableEvent[arrayLength];
        for (int i = 0; i < arrayLength; i++) {
            JSONObject eventObj = (JSONObject) array.get(i);

            TimetableEvent event = new TimetableEvent();
            event.setId((String) eventObj.opt("id"));
            event.setName(eventObj.getString("name"));
            event.setDescription(eventObj.getString("description"));
View Full Code Here

TOP

Related Classes of org.openfaces.org.json.JSONArray

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.