protected DataListBinder createDataListBinderFromRequestInternal(
      AppDefinition appDef, String datalistId, String binderId, HttpServletRequest request) {
    DataListBinder binder = null;
    if (binderId != null && binderId.trim().length() > 0) {
      // create binder
      binder = dataListService.getBinder(binderId);

      if (request != null) {
        // get request params
        Enumeration e = request.getParameterNames();
        while (e.hasMoreElements()) {
          String paramName = (String) e.nextElement();
          if (paramName.startsWith(PREFIX_BINDER_PROPERTY)) {
            String[] paramValue = (String[]) request.getParameterValues(paramName);
            String propName = paramName.substring(PREFIX_BINDER_PROPERTY.length());

            String value = CsvUtil.getDeliminatedString(paramValue);

            if (value.contains(SecurityUtil.ENVELOPE)
                || value.contains(PropertyUtil.PASSWORD_PROTECTED_VALUE)) {
              DatalistDefinition datalist = datalistDefinitionDao.loadById(datalistId, appDef);

              if (datalist != null) {
                value = PropertyUtil.propertiesJsonStoreProcessing(datalist.getJson(), value);
              }
            }

            binder.setProperty(propName, AppUtil.processHashVariable(value, null, null, null));
          }
        }
      }
    }
    return binder;
  }
  @RequestMapping(
      value = {
        "/console/app/(*:appId)/(~:appVersion)/datalist/builderPreview/(*:id)",
        "/client/app/(*:appId)/(*:appVersion)/datalist/(*:id)"
      })
  public String preview(
      ModelMap map,
      HttpServletRequest request,
      @RequestParam("appId") String appId,
      @RequestParam(value = "appVersion", required = false) String appVersion,
      @RequestParam("id") String id,
      @RequestParam(required = false) String json)
      throws Exception {
    String view = "dbuilder/view";

    // get current app to set into thread
    AppDefinition appDef = appService.getAppDefinition(appId, appVersion);

    try {
      // get data list
      DataList dataList = new DataList();
      if (json != null && !json.trim().isEmpty()) {

        String tempJson = json;
        if (tempJson.contains(SecurityUtil.ENVELOPE)
            || tempJson.contains(PropertyUtil.PASSWORD_PROTECTED_VALUE)) {
          DatalistDefinition datalistDef = datalistDefinitionDao.loadById(id, appDef);

          if (datalistDef != null) {
            tempJson = PropertyUtil.propertiesJsonStoreProcessing(datalistDef.getJson(), tempJson);
          }
        }

        dataList =
            dataListService.fromJson(AppUtil.processHashVariable(tempJson, null, null, null));
        map.addAttribute("json", json);
      } else {
        dataList = parseFromJsonParameter(map, dataList, id, request);
      }

      map.addAttribute("dataList", dataList);

    } catch (Exception ex) {
      StringWriter out = new StringWriter();
      ex.printStackTrace(new PrintWriter(out));
      String message = ex.toString();
      message += "\r\n<pre class=\"stacktrace\">" + out.getBuffer() + "</pre>";
      map.addAttribute("error", message);
    }

    // set map into model to be used in the JSP template
    map.addAttribute("properties", new HashMap(map));
    return view;
  }
  protected DataList parseFromJsonParameter(
      ModelMap map, DataList dataList, String id, HttpServletRequest request) {
    // get parameters

    String jsonParam = new ParamEncoder(id).encodeParameterName("json");
    String json = request.getParameter(jsonParam);

    // use preview json if available
    if (json != null && json.trim().length() > 0) {
      try {
        String tempJson = json;
        if (tempJson.contains(SecurityUtil.ENVELOPE)
            || tempJson.contains(PropertyUtil.PASSWORD_PROTECTED_VALUE)) {
          AppDefinition appDef = AppUtil.getCurrentAppDefinition();
          DatalistDefinition datalist = datalistDefinitionDao.loadById(id, appDef);

          if (datalist != null) {
            tempJson = PropertyUtil.propertiesJsonStoreProcessing(datalist.getJson(), tempJson);
          }
        }

        dataList =
            dataListService.fromJson(AppUtil.processHashVariable(tempJson, null, null, null));
        dataList.setId(id);
      } catch (Exception ex) {
        map.addAttribute("dataListError", ex.toString());
      }
    } /* else {
      json = dataListService.toJson(dataList);
      }*/

    String jsonEncoded = null;
    try {
      if (json != null) {
        jsonEncoded = URLEncoder.encode(json, "UTF-8");
      }
    } catch (Exception ex) {
      LogUtil.error(this.getClass().getName(), ex, "parseFromJsonParameter Error!");
    }

    // set for view
    map.addAttribute("json", json);
    map.addAttribute("jsonEncoded", jsonEncoded);
    map.addAttribute("jsonParam", jsonParam);
    return dataList;
  }