Package org.richfaces.json

Examples of org.richfaces.json.JSONArray


*/
public class PieStrategy implements ChartStrategy{

    @Override
    public Object export(ChartDataModel model) throws IOException {
        JSONArray jsData = new JSONArray();
        for (Iterator it = model.getData().entrySet().iterator(); it.hasNext();) {
            JSONObject point = new JSONObject();
            Map.Entry entry = (Map.Entry) it.next();
            try{
                point.put("label", entry.getKey());
                point.put("data", entry.getValue());
            }catch (JSONException ex){
                throw new IOException(ex);
            }
            jsData.put(point);
        }
        return jsData;
    }
View Full Code Here


        keys.remove(key);
    }
   
    public JSONObject defaultExport() throws IOException{
        JSONObject output = new JSONObject();
        JSONArray jsdata;

        //data
        jsdata = new JSONArray();
        /*for (Iterator it = getData().entrySet().iterator(); it.hasNext();) {
            JSONArray point = new JSONArray();
            Map.Entry entry = (Map.Entry) it.next();
            point.put(entry.getKey());
            point.put(entry.getValue());
            jsdata.put(point);
        }*/
       
        for (T key : keys) {
            JSONArray point = new JSONArray();
            S value = (S) data.get(key);
            point.put(key);
            point.put(value);
            jsdata.put(point);
        }
       
        ChartRendererBase.addAttribute(output,"data", jsdata);
        //label
View Full Code Here

class DateLineStrategy implements ChartStrategy {

    @Override
    public Object export(ChartDataModel model) throws IOException {
        JSONObject output = new JSONObject();
        JSONArray jsdata;

        //data
        jsdata = new JSONArray();
        for (Iterator it = model.getData().entrySet().iterator(); it.hasNext();) {
            JSONArray point = new JSONArray();
            Map.Entry entry = (Map.Entry) it.next();
            point.put(((Date)entry.getKey()).getTime());
            point.put(entry.getValue());
            jsdata.put(point);
        }
        ChartRendererBase.addAttribute(output,"data", jsdata);
        //label
        ChartRendererBase.addAttribute(output, "label", model.getAttributes().get("label"));
View Full Code Here

        private boolean nodata;
        public VisitChart(AbstractChart ch) {
            this.nodata=true;
            this.chart = ch;
            this.chartType = null;
            this.data = new JSONArray();
            this.seriesSpecificHandlers = new JSONObject();
            this.plotClickHandlers = new JSONArray();
            this.plothoverHandlers = new JSONArray();
           
            try{
                addAttribute(seriesSpecificHandlers, "onplotclick", plotClickHandlers);
                addAttribute(seriesSpecificHandlers, "onplothover", plothoverHandlers);
            } catch (IOException ex){
View Full Code Here

            collection = (Collection<?>) suggestions;
        } else {
            throw new IllegalArgumentException("Unhandled type (" + suggestions.getClass() + ") of suggestions attribute for autocomplete component");
        }
       
        return new JSONArray(collection);
    }
View Full Code Here

   */
  private void init(UIExtendedDataTable extendedDataTable, JSONCollection collection){
    value = null;
    if ((collection != null) && (collection.size()>0)){
      //try to restore state from collection
      value = new JSONArray(collection);
    }
   
    if (value == null){
      createDefaultColumnsOrder(extendedDataTable);
    }
View Full Code Here

 
  /**
   * Create default column order based on component children.
   */
  private void createDefaultColumnsOrder(UIExtendedDataTable extendedDataTable){
    value = new JSONArray();
    for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
      UIColumn col = iter.next();
      value.put(col.getId());
    }
  }
View Full Code Here

    else{
      //add at proper position
      list.add((targetIndex + (dropBefore ? 0 : 1)), sourceColumnId);
    }
    //convert from list to JSON
    value = new JSONArray(list);
  }
View Full Code Here

     * Initialize state from an extendedDataTable
     */
    ColumnsOrder (UIDataTableBase extendedDataTable) {
        String[] columnsOrder = (String[]) extendedDataTable.getAttributes().get("columnsOrder");
        if (columnsOrder != null) {
            json = new JSONArray(Arrays.asList(columnsOrder));
        }
    }
View Full Code Here

    /**
     * Initialize state from JSON
     */
    ColumnsOrder (JSONCollection json) {
        if ((json != null) && (json.size() > 0)) {
            this.json = new JSONArray(json);
        }
    }
View Full Code Here

TOP

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