Package org.openfaces.org.json

Examples of org.openfaces.org.json.JSONObject


        boolean isPortletRequest = AjaxUtil.isPortletRequest(context);

        if (requestMap.containsKey(AjaxUtil.AJAX_SUPPORT_RENDERED) || requestMap.containsKey(RENDERING)) {
            String ajaxMessageHTML = dpm.getAjaxMessageHTML();

            JSONObject backgroundLayerParams = null;
            if (dpm.getFillBackground()) {
                backgroundLayerParams = new JSONObject();
                Rendering.addJsonParam(backgroundLayerParams, "className", new StyleParam(dpm, "background", "o_ajax_blockingLayer"));
                Rendering.addJsonParam(backgroundLayerParams, "transparency", /*don't remove (double) cast -- the other function will be invoked*/(double) dpm.getBackgroundTransparency());
                Rendering.addJsonParam(backgroundLayerParams, "transparencyTransitionPeriod", /*don't remove (int) cast -- the other function will be invoked*/(int) dpm.getBackgroundTransparencyTransitionPeriod());
            }
            Styles.renderStyleClasses(context, dpm, true, true);
View Full Code Here


    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);
            }
View Full Code Here

    }

    public static Object getStylesMapAsJSONObject(Map<Object, String> map) {
        if (map == null || map.size() == 0)
            return null;
        JSONObject result = new JSONObject();
        for (Map.Entry<Object, String> entry : map.entrySet()) {
            Object key = entry.getKey();
            String className = entry.getValue();
            try {
                result.put(key.toString(), className);
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
        return result;
View Full Code Here

        JSONArray resourcesJsArray = DataUtil.listToJSONArray(resources, timeZoneParam);
        timetableView.getAttributes().put(USE_RESOURCE_SEPARATION_MODE_ATTR, resourcesJsArray.length() > 0);

        String clientId = timetableView.getClientId(context);

        JSONObject editingOptions = getEditingOptionsObj(timetableView);
        JSONObject stylingParams = getStylingParamsObj(context, timetableView);
        JSONObject calendarOptions = getCalendarOptionsObj(timetableView);

        TimeZone timeZone = (timetableView.getTimeZone() != null)
                ? timetableView.getTimeZone()
                : TimeZone.getDefault();
        boolean editable = timetableView.isEditable();
        boolean thereIsChangeListener = timetableView.getTimetableChangeListener() != null ||
                timetableView.getTimetableChangeListeners().length > 0;
        if (editable && !thereIsChangeListener) {
            Log.log(context, "The " + getComponentName() + " with clientID=[" + clientId + "] is set to be editable, but is not configured to accept the changes. You should either make it read-only explicitly (using editable=\"false\" attribute), or define timetableChangeListener attribute to accept the changes (see " + getComponentName() + " reference).");
            editable = false;
        }
        List<AbstractTimetableEvent> events = new ArrayList<AbstractTimetableEvent>();
        JSONObject eventParams = composeEventParams(context, timetableView, events);
        Map<String, AbstractTimetableEvent> loadedEvents = timetableView.getLoadedEvents();
        loadedEvents.clear();
        for (AbstractTimetableEvent event : events) {
            loadedEvents.put(event.getId(), event);
        }
View Full Code Here

            requestMap.put(END_TIME, prevEndTimeValue);
        }

        JSONArray eventsJsArray = DataUtil.listToJSONArray(events, timeZoneParam);

        JSONObject eventParams = new JSONObject();
        try {
            eventParams.put("events", eventsJsArray);
            eventParams.put("from", DataUtil.formatDateTimeForJs(startTime, timeZone));
            eventParams.put("to", DataUtil.formatDateTimeForJs(endTime, timeZone));
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
        return eventParams;
    }
View Full Code Here

    protected Date getLastDayForDefaultPeriod(TimeScaleTable timetableView, TimeZone timeZone) {
        return timetableView.getDay();
    }

    private JSONObject getStylingParamsObj(FacesContext context, TimeScaleTable timetableView) {
        JSONObject stylingParams = new JSONObject();


        Styles.addStyleJsonParam(context, timetableView, stylingParams, "rolloverClass",
                timetableView.getRolloverStyle(), timetableView.getRolloverClass());
        Styles.addStyleJsonParam(context, timetableView, stylingParams, "resourceHeadersRowClass",
View Full Code Here

        List<BaseColumn> allColumns = getAllColumns();
        TableStyles tableStyles = getTableStyles();
        Map<Object, String> rowStylesMap = getRowStylesMap();
        Map<Object, String> cellStylesMap = getCellStylesMap();

        JSONObject result = new JSONObject();
        Rendering.addJsonParam(result, "header", getHeader().getInitParam(defaultStyles));
        Rendering.addJsonParam(result, "body", getBody().getInitParam(defaultStyles));
        Rendering.addJsonParam(result, "footer", getFooter().getInitParam(defaultStyles));
        Rendering.addJsonParam(result, "columns", getColumnHierarchyParam(facesContext, visibleColumns));
        Rendering.addJsonParam(result, "logicalColumns", getColumnHierarchyParam(facesContext, allColumns));
View Full Code Here

    }

    private Object getScrollingParam() {
        if (scrolling == null)
            return null;
        JSONObject result = new JSONObject();
        int leftFixedCols = getLeftFixedCols();
        int rightFixedCols = getRightFixedCols();
        try {
            result.put("leftFixedCols", leftFixedCols);
            result.put("rightFixedCols", rightFixedCols);
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
        boolean autoSaveState = scrolling.getAutoSaveState();
        Rendering.addJsonParam(result, "horizontal", scrolling.isHorizontal(), false);
View Full Code Here

                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

        }
        return columnsArray;
    }

    private JSONObject getColumnParams(FacesContext context, BaseColumn columnOrGroup, int level) throws JSONException {
        JSONObject columnObj = new JSONObject();

        columnObj.put("columnId", columnOrGroup.getId());

        UIComponent styleOwnerComponent = getComponent();
        boolean noDataRows = getBody().getNoDataRows();
        boolean ordinaryColumn = !(columnOrGroup instanceof ColumnGroup);

        String defaultColumnStyleClass = getColumnDefaultClass(columnOrGroup);
        String colClassName = Styles.getCSSClass(context,
                styleOwnerComponent, columnOrGroup.getStyle(), StyleGroup.regularStyleGroup(level), columnOrGroup.getStyleClass(), defaultColumnStyleClass
        );

        String resizingWidthClass;
        {
            AbstractTable table = styleOwnerComponent instanceof AbstractTable ? (AbstractTable) styleOwnerComponent : null;
            ColumnResizing columnResizing = (table != null) ? table.getColumnResizing() : null;
            ColumnResizingState columnResizingState = columnResizing != null ? columnResizing.getResizingState() : null;
            String resizingWidth = columnResizingState != null ? columnResizingState.getColumnWidth(columnOrGroup.getId()) : null;
            if (resizingWidth != null) {
                resizingWidthClass = Styles.getCSSClass(context, table, "width: " + resizingWidth, StyleGroup.selectedStyleGroup(), null
                );
            } else
                resizingWidthClass = null;
        }

        columnObj.put("className", Styles.mergeClassNames(colClassName, resizingWidthClass));

        appendColumnEventsArray(columnObj,
                columnOrGroup.getOnclick(),
                columnOrGroup.getOndblclick(),
                columnOrGroup.getOnmousedown(),
                columnOrGroup.getOnmouseover(),
                columnOrGroup.getOnmousemove(),
                columnOrGroup.getOnmouseout(),
                columnOrGroup.getOnmouseup());
        boolean hasCellWrappers = columnOrGroup instanceof TreeColumn;
        if (hasCellWrappers)
            columnObj.put("hasCellWrappers", hasCellWrappers);

        TableHeader tableHeader = getHeader();
        CellCoordinates headerCellCoordinates = tableHeader.findCell(columnOrGroup, CellKind.COL_HEADER);
        if (headerCellCoordinates != null) {
            JSONObject header = new JSONObject();
            columnObj.put("header", header);
            header.put("pos", headerCellCoordinates.asJSONObject());
            header.put("className", Styles.getCSSClass(context, styleOwnerComponent,
                    columnOrGroup.getHeaderStyle(), columnOrGroup.getHeaderClass()));
            appendColumnEventsArray(header,
                    columnOrGroup.getHeaderOnclick(),
                    columnOrGroup.getHeaderOndblclick(),
                    columnOrGroup.getHeaderOnmousedown(),
                    columnOrGroup.getHeaderOnmouseover(),
                    columnOrGroup.getHeaderOnmousemove(),
                    columnOrGroup.getHeaderOnmouseout(),
                    columnOrGroup.getHeaderOnmouseup());
        }
        if (ordinaryColumn && tableHeader.hasSubHeader()) {
            CellCoordinates subHeaderCellCoordinates = tableHeader.findCell(columnOrGroup, CellKind.COL_SUBHEADER);
            if (subHeaderCellCoordinates != null) {
                JSONObject subHeader = new JSONObject();
                columnObj.put("subHeader", subHeader);
                subHeader.put("pos", subHeaderCellCoordinates.asJSONObject());
                subHeader.put("className", Styles.getCSSClass(context, styleOwnerComponent, columnOrGroup.getSubHeaderStyle(), columnOrGroup.getSubHeaderClass()));
            }
        }
        if (!noDataRows) {
            JSONObject body = new JSONObject();
            columnObj.put("body", body);
            body.put("className", Styles.getCSSClass(context,
                    styleOwnerComponent, getColumnBodyStyle(columnOrGroup), StyleGroup.regularStyleGroup(level), getColumnBodyClass(columnOrGroup), null
            ));
            appendColumnEventsArray(body,
                    columnOrGroup.getBodyOnclick(),
                    columnOrGroup.getBodyOndblclick(),
                    columnOrGroup.getBodyOnmousedown(),
                    columnOrGroup.getBodyOnmouseover(),
                    columnOrGroup.getBodyOnmousemove(),
                    columnOrGroup.getBodyOnmouseout(),
                    columnOrGroup.getBodyOnmouseup());
        }
        TableFooter tableFooter = getFooter();
        CellCoordinates footerCellCoordinates = tableFooter.findCell(columnOrGroup, CellKind.COL_HEADER);
        if (footerCellCoordinates != null) {
            JSONObject footer = new JSONObject();
            columnObj.put("footer", footer);
            footer.put("pos", footerCellCoordinates.asJSONObject());
            footer.put("className", Styles.getCSSClass(context, styleOwnerComponent, columnOrGroup.getFooterStyle(), columnOrGroup.getFooterClass()));
            appendColumnEventsArray(footer,
                    columnOrGroup.getFooterOnclick(),
                    columnOrGroup.getFooterOndblclick(),
                    columnOrGroup.getFooterOnmousedown(),
                    columnOrGroup.getFooterOnmouseover(),
View Full Code Here

TOP

Related Classes of org.openfaces.org.json.JSONObject

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.