Example #1
0
  protected DataList getDataList() throws BeansException {
    if (cacheDataList == null) {
      // get datalist
      ApplicationContext ac = AppUtil.getApplicationContext();
      AppService appService = (AppService) ac.getBean("appService");
      DataListService dataListService = (DataListService) ac.getBean("dataListService");
      DatalistDefinitionDao datalistDefinitionDao =
          (DatalistDefinitionDao) ac.getBean("datalistDefinitionDao");
      String id = getPropertyString("datalistId");
      AppDefinition appDef =
          appService.getAppDefinition(
              getRequestParameterString("appId"), getRequestParameterString("appVersion"));
      DatalistDefinition datalistDefinition = datalistDefinitionDao.loadById(id, appDef);

      if (datalistDefinition != null) {
        cacheDataList = dataListService.fromJson(datalistDefinition.getJson());

        if (getPropertyString(Userview.USERVIEW_KEY_NAME) != null
            && getPropertyString(Userview.USERVIEW_KEY_NAME).trim().length() > 0) {
          cacheDataList.addBinderProperty(
              Userview.USERVIEW_KEY_NAME, getPropertyString(Userview.USERVIEW_KEY_NAME));
        }
        if (getKey() != null && getKey().trim().length() > 0) {
          cacheDataList.addBinderProperty(Userview.USERVIEW_KEY_VALUE, getKey());
        }

        cacheDataList.setActionPosition(getPropertyString("buttonPosition"));
        cacheDataList.setSelectionType(getPropertyString("selectionType"));
        cacheDataList.setCheckboxPosition(getPropertyString("checkboxPosition"));
      }
    }
    return cacheDataList;
  }
  @RequestMapping("/app/(*:appId)/(~:appVersion)/datalist/embed")
  public String embedDatalist(
      ModelMap model,
      @RequestParam("appId") String appId,
      @RequestParam(value = "version", required = false) String version,
      HttpServletRequest request,
      @RequestParam("_submitButtonLabel") String buttonLabel,
      @RequestParam("_callback") String callback,
      @RequestParam("_setting") String callbackSetting,
      @RequestParam(required = false) String id,
      @RequestParam(value = "_listId", required = false) String listId,
      @RequestParam(value = "_type", required = false) String selectionType)
      throws JSONException {
    AppDefinition appDef = appService.getAppDefinition(appId, version);
    DatalistDefinition datalistDefinition = datalistDefinitionDao.loadById(listId, appDef);
    String json = datalistDefinition.getJson();
    DataList dataList = dataListService.fromJson(json);
    dataList.setSelectionType(selectionType);

    model.addAttribute("id", id);
    model.addAttribute("json", json);
    model.addAttribute("buttonLabel", buttonLabel);
    model.addAttribute("dataList", dataList);
    model.addAttribute("setting", callbackSetting);
    model.addAttribute("callback", callback);
    return "dbuilder/embedDatalist";
  }