Package org.primefaces.json

Examples of org.primefaces.json.JSONObject


                }
                else if (isBean(paramValue)) {
                    write("\"");
                    write(paramName);
                    write("\":");
                    write(new JSONObject(paramValue).toString());
                }
                else {
                    String json = new JSONObject().put(paramName, paramValue).toString();
                    write(json.substring(1, json.length() - 1));
                }

                if (it.hasNext()) {
                    write(",");
View Full Code Here


       
        try {
            String json;
           
            if(object instanceof Map) {
                json = new JSONObject((Map) object).toString();
            }
            else if (BeanUtils.isBean(object.getClass())) {
                json = new JSONObject(object).toString();
            else {
                json = new JSONObject().put(PRIMITIVE_DATA, object).toString();
            }

            return json;
        }
        catch (JSONException e) {
View Full Code Here

        if(s == null || s.trim().length() == 0 ) {
            return null;
        }
        else {
            try
                return new JSONObject(s);
            } catch (JSONException ex) {
                throw new RuntimeException(ex);
            }
        }
    }
View Full Code Here

    Object msg = event.getMessage();
    String jsonData = null;
    try {
      jsonData = isBean(msg) ? "{\"data\":"
          + new JSONObject(msg).toString() + "}" : new JSONObject()
          .put("data", msg.toString()).toString();
    } catch (JSONException e) {
      throw new FacesException(e.getMessage());
    }
View Full Code Here

    HttpServletResponse response = ((HttpServletResponse) event.getResource().getResponse());

    Object msg = event.getMessage();
    String jsonData = null;
    try {
      jsonData = isBean(msg) ? "{\"data\":" + new JSONObject(msg).toString() + "}" : new JSONObject().put("data", msg.toString()).toString();
    } catch (JSONException e) {
      throw new FacesException(e.getMessage());
    }

    String widget = request.getParameter("widget");
View Full Code Here

                    for(Iterator<String> it = params.keySet().iterator(); it.hasNext();) {
                        String paramName = it.next();
                        Object paramValue = params.get(paramName);
                       
                        if(isBean(paramValue)) {
                            jsonBuilder.append("\"").append(paramName).append("\":").append(new JSONObject(paramValue).toString());
                        }
                        else {
                            String json = new JSONObject().put(paramName, paramValue).toString();
                            jsonBuilder.append(json.substring(1, json.length() - 1));
                        }
                       
                        if(it.hasNext()) {
                            jsonBuilder.append(",");
View Full Code Here

      // and columns updated
      // this is so that multiple updates to the same cell overwrite
      // previous deltas prior to submission
      // we don't care about the property names, just the values, which
      // we'll process in turn
      JSONObject obj = new JSONObject(jsonData);
      @SuppressWarnings("unchecked")
      Iterator<String> keys = obj.keys();
      while (keys.hasNext()) {
        final String key = keys.next();
        // data comes in: [row, col, oldValue, newValue]
        JSONArray update = obj.getJSONArray(key);
        final int row = update.getInt(0);
        final int col = sheet.getMappedColumn(update.getInt(1));
        final String newValue = update.getString(3);
        sheet.setSubmittedValue(context, row, col, newValue);
      }
View Full Code Here

                }
                else if (isBean(paramValue)) {
                    write("\"");
                    write(paramName);
                    write("\":");
                    write(new JSONObject(paramValue).toString());
                }
                else {
                    String json = new JSONObject().put(paramName, paramValue).toString();
                    write(json.substring(1, json.length() - 1));
                }

                if (it.hasNext()) {
                    write(",");
View Full Code Here

      for(String paramName : params.keySet()) {
       
        writer.write("<callbackParam>");
        try {
          Object paramValue = params.get(paramName);
          String json = isBean(paramValue) ? "{\"" + paramName + "\":" + new JSONObject(paramValue).toString() + "}": new JSONObject().put(paramName, paramValue).toString();
          writer.write(json);
        } catch (JSONException e) {
          logger.log(Level.SEVERE, "Error in serializing callback parameter \"{0}\"", paramName);
          throw new FacesException(e.getMessage());
        }
View Full Code Here

    HttpServletResponse response = ((HttpServletResponse) event.getResource().getResponse());

    Object msg = event.getMessage();
    String jsonData = null;
    try {
      jsonData = isBean(msg) ? "{\"data\":" + new JSONObject(msg).toString() + "}" : new JSONObject().put("data", msg.toString()).toString();
    } catch (JSONException e) {
      throw new FacesException(e.getMessage());
    }

    String widget = request.getParameter("widget");
View Full Code Here

TOP

Related Classes of org.primefaces.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.