Package org.openfaces.org.json

Examples of org.openfaces.org.json.JSONArray


                }
            }
            return jsonObj;
        } else if (jsonParam.has(AJAX_FILES_REQUEST)) {
            JSONObject jsonObj = new JSONObject();
            JSONArray files = (JSONArray) jsonParam.get(AJAX_PARAM_FILES_ID);
            boolean allUploaded = true;
            Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
            for (int i = 0; i < files.length(); i++) {
                JSONArray file = files.getJSONArray(i);
                if (file.getString(3).equals("SUCCESSFUL")) {
                    if (!sessionMap.containsKey(file.getString(0))) {
                        allUploaded = false;
                        break;
                    }
                }
            }
            JSONArray fileSizes = new JSONArray();
            if (allUploaded) {
                List<FileUploadItem> filesItems = new LinkedList<FileUploadItem>();
                for (int i = 0; i < files.length(); i++) {
                    JSONArray file = files.getJSONArray(i);
                    if (file.getString(3).equals("SUCCESSFUL")) {
                        FileUploadItem fileUploadItem = (FileUploadItem) sessionMap.get(file.getString(0));
                        filesItems.add(fileUploadItem);
                        sessionMap.remove(file.getString(0));

                        JSONArray jsonArray = new JSONArray();
                        jsonArray.put(file.getString(4));
                        jsonArray.put(fileUploadItem.getFile().length());
                        fileSizes.put(jsonArray);

                    } else if (file.getString(3).equals("STOPPED")) {
                        filesItems.add(new FileUploadItem(file.getString(2), null, FileUploadStatus.STOPPED));
                        sessionMap.remove(PROGRESS_ID + file.getString(1));
View Full Code Here


        if (scrolling == null)
            position = new Point();
        else {
            int x, y;
            try {
                JSONArray arr = new JSONArray(scrolling);
                x = arr.getInt(0);
                y = arr.getInt(1);
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
            position = new Point(x, y);
        }
View Full Code Here

    }

    @Override
    protected void decodeSelectionFromIndexes(List<?> indexes) {
        if (indexes.size() != 0) {
            JSONArray item = (JSONArray) indexes.get(0);
            try {
                Integer rowIndex = (Integer) item.get(0);
                String columnId = (String) item.get(1);
                setCellId(getRowDataByRowIndex(rowIndex), columnId);
            } catch (JSONException e) {
                throw new IllegalArgumentException("Cell selection doesn't have correct attributes : rowIndex and columnId", e);
            }
        } else {
View Full Code Here

        // to ensure that it gets submitted with Ajax when only table is included into the Ajax "execute" phase.
        ResponseWriter writer = context.getResponseWriter();
        String valueFieldName = getClientId(context);
        Rendering.renderHiddenField(writer, valueFieldName, "");

        JSONArray checkedRowIndexes = new JSONArray();
        if (selectedRows == null || selectedRows.getModel() == null)
            assignDataModel();
        /*getSelectedRowKeys can return List of Integer if it's rowSelection or JSONArray if it's cellSelection
        * There is check on MultipleNodeSelection so getSelectedRowKeys guarantees to return List of Integer
        * */
        AbstractTable table = Components.getParentWithClass(this, AbstractTable.class);

        @SuppressWarnings(value = "unchecked") List<Integer> rowIndexes = (List<Integer>) selectedRows.encodeSelectionIntoIndexes(table.getUnDisplayedSelectionAllowed());
        for (Integer checkedRowIdx : rowIndexes) {
            checkedRowIndexes.put(checkedRowIdx);
        }


        int colIndex = table.getRenderedColumns().indexOf(this);
        buf.functionCall("O$.Table._initCheckboxColumn",
View Full Code Here

        return url;
    }

    @Override
    public Object encodeExpansionDataAsJsObject(FacesContext context) {
        JSONArray result = new JSONArray();
        result.put(getToggleImageUrl(context, true));
        result.put(getToggleImageUrl(context, false));
        return result;
    }
View Full Code Here

    }

    @Override
    protected List<?> convertFieldValue(String fieldValue) {
        try {
            JSONArray array = new JSONArray(fieldValue);
            List<JSONArray> indexes = new ArrayList<JSONArray>();
            for (int i = 0; i < array.length(); i++) {
                indexes.add((JSONArray) array.get(i));

            }
            return indexes;
        } catch (JSONException e) {
            throw new IllegalStateException("Wrong fieldValue for selecting cell", e);
View Full Code Here

    public String getSelectableItems() {
        return "cells";
    }

    protected final JSONArray transformToJSON(CellId cellId) throws JSONException {
        return new JSONArray(new Object[]{getRowIndexByRowData(cellId.getRowData()), cellId.getColumnId()});
    }
View Full Code Here

        EventActionBar actionBar = (EventActionBar) params_.get(EventActionBar.class);

        JSONObject result = new JSONObject();
        if (getId() != null)
            result.put("id", getClientId(context));
        result.put("image", new JSONArray(Arrays.asList(
                getActionImageUrl(context, this),
                Resources.applicationURL(context, getRolloverImageUrl()),
                Resources.applicationURL(context, getPressedImageUrl()))));
        result.put("style", new JSONArray(Arrays.asList(
                Styles.getCSSClass(context, actionBar, getStyle(), "o_eventActionButton", getStyleClass()),
                Styles.getCSSClass(context, actionBar, getRolloverStyle(), getRolloverClass()),
                Styles.getCSSClass(context, actionBar, getPressedStyle(), getPressedClass()))));
        result.put("onclick", getOnclick());
        result.put("hint", getHint());
View Full Code Here

            protected Object getExecuteParam(FacesContext context, OUICommand ajax, Iterable<String> execute) {
                return new RawScript("O$._executeIds['" + id + "']");
            }
        };

        JSONArray renderArray = ajaxInitializer.getRenderArray(context, (OUICommand) action, ajax.getRender());
        String idExpression = "O$._renderIds['" + id + "']";
        Script render = new RawScript("(" + idExpression + " ? " + idExpression + " : " + renderArray.toString() + ")");

        buf.functionCall("O$._ajaxReload",
                render,
                ajaxInitializer.getAjaxParams(context, ajax)).semicolon();
        return buf.toString();
View Full Code Here

    private static final String EXPRESSION_SUFFIX = "}";
   
    public static ThreadLocal<Boolean> BUILDING_VIEW = new ThreadLocal<Boolean>();

    public JSONArray getRenderArray(FacesContext context, UIComponent sourceComponent, Iterable<String> render) {
        JSONArray idsArray = new JSONArray();
        if (render != null)
            for (String componentId : render) {
                if (componentId.startsWith(":")) {
                    idsArray.put(componentId.substring(1));
                    continue;
                }
                UIComponent component = findComponent_cached(context, sourceComponent, componentId);
                if (component == null) {
                    idsArray.put(componentId);
                    continue;
                }

                if (component instanceof UIData) {
                    UIData uiData = (UIData) component;
                    int savedRowIndex = uiData.getRowIndex();
                    uiData.setRowIndex(-1);
                    idsArray.put(component.getClientId(context));
                    uiData.setRowIndex(savedRowIndex);
                } else if (component instanceof OUIObjectIterator) {
                    OUIObjectIterator ouiObjectIterator = (OUIObjectIterator) component;
                    String savedObjectId = ouiObjectIterator.getObjectId();
                    ouiObjectIterator.setObjectId(null);
                    idsArray.put(component.getClientId(context));
                    ouiObjectIterator.setObjectId(savedObjectId);
                } else {
                    idsArray.put(component.getClientId(context));
                }
            }
        return idsArray;
    }
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.