Package org.openfaces.org.json

Examples of org.openfaces.org.json.JSONArray


    }

    protected Object getExecuteParam(FacesContext context,
                                     OUICommand command,
                                     Iterable<String> execute) {
        JSONArray renderArray = getRenderArray(context, command, execute);
        if (!(command instanceof Ajax)) {
            if (command instanceof ComponentConfigurator) {
                UIComponent configuredComponent = ((ComponentConfigurator) command).getConfiguredComponent();
                if (configuredComponent != null) {
                    String configuredId = configuredComponent.getClientId(context);
                    renderArray.put(configuredId);
                }
            }
            return renderArray;
        }
        Ajax ajax = (Ajax) command;
        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
                renderArray.put(invokerId);
            }
        }
        return renderArray;
    }
View Full Code Here


                list.add((AbstractUIEventContent) child);
            }
        }

        if (! list.isEmpty()) {
            JSONArray eventContent = DataUtil.listToJSONArray(list, null);
            Rendering.addJsonParam(obj, "content", eventContent);
        }

        try {
            Styles.renderStyleClasses(context, this);
View Full Code Here

        throw new IllegalArgumentException("Unknown criterion type: " + jsonCriterionType);
    }

    private static List<FilterCriterion> parseComposite(JSONObject jsonObject, PropertyLocatorFactory locatorFactory) throws JSONException {
        List<FilterCriterion> result = new ArrayList<FilterCriterion>();
        JSONArray criteria = jsonObject.getJSONArray(CRITERIA);
        for (int i = 0; i < criteria.length(); i++) {
            result.add(parse(criteria.getJSONObject(i), locatorFactory));
        }
        return result;
    }
View Full Code Here

    private JSONObject process(CompositeFilterCriterion criterion, CriterionType type) {
        try {
            JSONObject result = new JSONObject();
            result.put(TYPE, type);
            JSONArray criteria = new JSONArray();
            for (FilterCriterion childCriterion : criterion.getCriteria()) {
                criteria.put(childCriterion.process(this));
            }
            result.put(CRITERIA, criteria);
            return result;
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

        return table.getClientId(context) + "::focused";
    }

    private void encodeSortingSupport(FacesContext context, AbstractTable table, ScriptBuilder buf) throws IOException {
        boolean atLeastOneColumnSortable1 = false;
        final JSONArray sortableColumnsIds = new JSONArray();
        for (BaseColumn column : table.getAllColumns()) {
            boolean sortable;
            Boolean columnSortableAttr = (Boolean) column.getAttributes().get("sortable");
            if (columnSortableAttr != null)
                sortable = columnSortableAttr;
            else {
                ValueExpression sortingExpression = column.getColumnSortingExpression();
                sortable = (sortingExpression != null);
            }
            if (sortable) sortableColumnsIds.put(column.getId());
            atLeastOneColumnSortable1 |= sortable;
        }
        boolean atLeastOneColumnSortable = atLeastOneColumnSortable1;
        if (!atLeastOneColumnSortable)
            return;
View Full Code Here

        String sortingRulesStr = requestParameterMap.get(paramName);
        if (Rendering.isNullOrEmpty(sortingRulesStr)) return;

        List<SortingRule> sortingRules = new ArrayList<SortingRule>();
        try {
            JSONArray sortingRulesJson = new JSONArray(sortingRulesStr);
            for (int i = 0, count = sortingRulesJson.length(); i < count; i++) {
                JSONObject jsonObject = sortingRulesJson.getJSONObject(i);
                sortingRules.add(new SortingRule(jsonObject));
            }
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

        }

        ResponseWriter writer = context.getResponseWriter();
        Rendering.renderHiddenField(writer, getExpandedNodesFieldName(context, table), null);

        JSONArray treeColumnParamsArray = new JSONArray();
        List<BaseColumn> renderedColumns = table.getAdaptedRenderedColumns();
        for (BaseColumn column : renderedColumns) {
            if (!(column instanceof TreeColumn))
                continue;
            TreeColumn treeColumn = (TreeColumn) column;
            Object columnParams = treeColumn.encodeParamsAsJsObject(context);
            treeColumnParamsArray.put(columnParams != null ? columnParams : JSONObject.NULL);
        }

        buf.initScript(context, table, "O$.TreeTable._initFolding",
                treeStructure,
                treeColumnParamsArray,
View Full Code Here

     * @param defaultValue The default value to compare
     */
    public static void addJsonParam(JSONObject paramsObject, String paramName, Object paramValue, Object defaultValue) {
        if (paramValue instanceof Object[]) {
            Object[] params = ((Object[]) paramValue);
            JSONArray array = new JSONArray();
            for (Object param : params) {
                array.put(param);
            }
            paramValue = array;
        }
        if (paramValue instanceof List) {
            List params = ((List) paramValue);
            JSONArray array = new JSONArray();
            for (Object param : params) {
                array.put(param);
            }
            paramValue = array;
        }
        if (paramValue != null && !paramValue.equals(defaultValue))
            try {
View Full Code Here

        renderInitJS(facesContext, popupMenu);
    }

    private JSONArray getMenuItemParameters(PopupMenu popupMenu) {
        JSONArray menuItemParameters = new JSONArray();
        List<UIComponent> components = popupMenu.getChildren();
        for (UIComponent component : components) {
            if (component instanceof MenuItem) {
                MenuItem menuItem = (MenuItem) component;
                Map parameters = (Map) menuItem.getAttributes().get(MenuItemRenderer.MENU_ITEMS_PARAMETERS_KEY);
                if (parameters == null) {
                    parameters = new HashMap();
                }
                JSONObject obj = new JSONObject(parameters);
                menuItemParameters.put(obj);
            } else if (component instanceof MenuSeparator) {
                menuItemParameters.put(new JSONObject());
            }
        }
        return menuItemParameters;
    }
View Full Code Here

        String groupingRulesStr = requestParameterMap.get(paramName);
        if (Rendering.isNullOrEmpty(groupingRulesStr)) return;

        List<GroupingRule> groupingRules = new ArrayList<GroupingRule>();
        try {
            JSONArray sortingRulesJson = new JSONArray(groupingRulesStr);
            for (int i = 0, count = sortingRulesJson.length(); i < count; i++) {
                JSONObject jsonObject = sortingRulesJson.getJSONObject(i);
                groupingRules.add(new GroupingRule(jsonObject));
            }
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
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.