Package org.openfaces.org.json

Examples of org.openfaces.org.json.JSONObject


    public JSONObject toJSONObject(Map params_) throws JSONException {
        FacesContext context = FacesContext.getCurrentInstance();
        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());
        result.put("scope", getScope());
        return result;
    }
View Full Code Here


        Iterable<String> execute = getExecute();
        final Chart chart = (Chart) getParent();

        if (render != null || (execute != null && execute.iterator().hasNext())) {
            AjaxInitializer initializer = new AjaxInitializer();
            JSONObject ajaxParams = initializer.getAjaxParams(context, this);
            MethodExpression actionExpression = getActionExpression();
            if (actionExpression != null) {
                String expr = actionExpression.getExpressionString().trim();
                if (!expr.startsWith("#{")) throw new FacesException("<o:selection> action expression is expected to start with #{ symbols: " + expr);
                expr = expr.substring(2, expr.length() - 1);
                try {
                    ajaxParams.put("_action", expr);
                } catch (JSONException e) {
                    throw new RuntimeException(e);
                }
            }
            automaticChangeHandler = new ScriptBuilder().functionCall("O$._ajaxReload",
View Full Code Here

    public JSONObject toJSONObject(Map params) throws JSONException {
        TimeZone timeZone = (TimeZone) params.get("timeZone");
        if (timeZone == null)
            throw new IllegalArgumentException("TimetableEvent.toJSONObject requires the 'timeZone' parameter to be passed in the params map");
        JSONObject obj = new JSONObject();
        obj.put("id", id);
        if (resourceId != null)
            obj.put("resourceId", resourceId);
        obj.put("startStr", DataUtil.formatDateTimeForJs(start, timeZone));
        obj.put("endStr", DataUtil.formatDateTimeForJs(end, timeZone));
        if (customProperties != null) {
            JSONObject properties = new JSONObject();
            obj.put("customProperties", properties);
            Set<Map.Entry<String, Object>> entries = customProperties.entrySet();
            for (Map.Entry<String, Object> entry : entries) {
                String property = entry.getKey();
                Object value = entry.getValue();
                if (value instanceof Date)
                    value = DataUtil.formatDateTimeForJs((Date) value, timeZone);
                else if (value instanceof Color)
                    value = CSSUtil.formatColor((Color) value);
                properties.put(property, value);
            }
        }
        return obj;
    }
View Full Code Here

        this.styleClass = styleClass;
    }

    protected JSONObject getData() throws JSONException {
        FacesContext context = getFacesContext();
        JSONObject obj = new JSONObject();
        Styles.addStyleJsonParam(context, this, obj, "style", getStyle(), getStyleClass());
        return obj;
    }
View Full Code Here

        color = timetableEvent.getColor();
    }

    @Override
    public JSONObject toJSONObject(Map params) throws JSONException {
        JSONObject obj = super.toJSONObject(params);
        obj.put("name", name);
        obj.put("description", description);
        obj.put("color", DataUtil.colorAsHtmlColor(color));
        return obj;
    }
View Full Code Here

        return result;
    }

    public List<User> getFilteredUsersForStoredCriterion() throws JSONException {
        String jsonCriteria = getJsonCriteria();
        FilterCriterion storedCriteria = JSONBuilder.getInstance().parse(new JSONObject(jsonCriteria));
        Predicate predicate = PredicateBuilder.build(storedCriteria);
        ArrayList<User> result = new ArrayList<User>(users);
        CollectionUtils.filter(result, predicate);
        return result;
    }
View Full Code Here

    }


    public JSONObject getAjaxParams(FacesContext context, OUICommand command) {
        try {
            JSONObject result = new JSONObject();
            Iterable<String> execute = command.getExecute();
            boolean submitAjaxInvoker =
                    command instanceof ComponentConfigurator || // e.g. when using Ajax in table selection, submit table params automatically
                    (command instanceof Ajax &&
                            !((Ajax) command).isStandalone()
                            && ((Ajax) command).getSubmitInvoker());
            if (execute.iterator().hasNext() || submitAjaxInvoker) {
                result.put("execute", getExecuteParam(context, command, execute));
            }
            result.put("executeRenderedComponents", command.getExecuteRenderedComponents());
            String onajaxstart = command.getOnajaxstart();
            if (onajaxstart != null && onajaxstart.length() != 0) {
                result.put("onajaxstart", new AnonymousFunction(onajaxstart, "event"));
            }
            String onajaxend = command.getOnajaxend();
            if (onajaxend != null && onajaxend.length() != 0) {
                result.put("onajaxend", new AnonymousFunction(onajaxend, "event"));
            }
            String onerror = command.getOnerror();
            if (onerror != null && onerror.length() != 0) {
                result.put("onerror", new AnonymousFunction(onerror, "event"));
            }
            String onsuccess = command.getOnerror();
            if (onsuccess != null && onsuccess.length() != 0) {
                result.put("onsuccess", new AnonymousFunction(onsuccess, "event"));
            }
            Integer delayObj = (Integer) command.getAttributes().get("delay");
            int delay = delayObj != null ? delayObj : 0;
            if (delay > 0) {
                result.put("delay", delay);
                result.put("delayId", getAjaxComponentParam(context, command));
            }

            MethodExpression action = !(command instanceof Ajax) ? command.getActionExpression() : null;
            if (action != null) {
                String actionExpressionString = action.getExpressionString();
                validateExpressionString(actionExpressionString);
                result.put("_action", actionExpressionString.substring(
                        EXPRESSION_PREFIX.length(), actionExpressionString.length() - EXPRESSION_SUFFIX.length()));
                result.put("actionComponent", command.getClientId(context));
            }

            ValueExpression actionListener = command instanceof Ajax
                    ? command.getValueExpression("listener")
                    : command.getValueExpression("actionListener");
            if (actionListener != null) {
                String actionListenerExpressionString = actionListener.getExpressionString();
                validateExpressionString(actionListenerExpressionString);
                result.put("listener", actionListenerExpressionString.substring(EXPRESSION_PREFIX.length(),
                        actionListenerExpressionString.length() - EXPRESSION_SUFFIX.length()));
                result.put("actionComponent", getAjaxComponentParam(context, command));
            }

            result.put("immediate", command.isImmediate());
            return result;
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

            InputStreamReader reader = new InputStreamReader(input);
            char[] target = new char[BUFFER_SIZE];
            int charsRead = reader.read(target);
            String params = new String(target, 0, charsRead);
            try {
                JSONObject jParams = new JSONObject(params);
                JSONObject jValidatorTransportObject = jParams.getJSONObject("params");

                String jValue = jValidatorTransportObject.getString("value");
                JSONObject jValidator = jValidatorTransportObject.getJSONObject("validator");
                String javaClassName = jValidator.getString("javaClassName");
                if (javaClassName != null) {
                    Object validator = Class.forName(javaClassName).newInstance();
                    if (validator instanceof AjaxSupportedConverter) {
                        converter = ((AjaxSupportedConverter) validator).getConverter(context, jValidator);
                    }
View Full Code Here

        oncreate = (String) state[i++];
    }

    public JSONObject toJSONObject(Map params) throws JSONException {
        FacesContext context = getFacesContext();
        JSONObject obj = new JSONObject();
        Styles.addStyleJsonParam(context, this, obj, "style", getStyle(), getStyleClass());
        Styles.addStyleJsonParam(context, this, obj, "rolloverStyle", getRolloverStyle(), getRolloverClass());

        Styles.addStyleJsonParam(context, this, obj, "nameStyle", getNameStyle(), getNameClass());
        Styles.addStyleJsonParam(context, this, obj, "descriptionStyle", getDescriptionStyle(), getDescriptionClass());
View Full Code Here

            propertyLocator = PropertyLocator.getDefaultInstance(expression);
        } else {
            propertyLocator = locatorFactory.create(expression);
        }
        Map<String, Object> parameters = new HashMap<String, Object>();
        JSONObject jsonParameters = jsonObject.getJSONObject(PARAMETERS);
        for (Iterator keyIterator = jsonParameters.keys(); keyIterator.hasNext();) {
            String key = (String) keyIterator.next();
            Object parameterValue = parseParameter(jsonParameters.getJSONObject(key));
            parameters.put(key, parameterValue);
        }

        FilterCondition condition = FilterCondition.byName(jsonObject.getString(FILTER_CONDITION_NAME));
        boolean inverse = jsonObject.getBoolean(INVERSE);
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.