Esempio n. 1
0
  /**
   * 获取单Form面板元数据 @Methods Name forSaveSingleForm @Create 2009-3-4 By lee
   *
   * @param request
   * @return @ReturnType String
   */
  private String forSaveSingleForm(HttpServletRequest request) {
    String json = "";
    String id = request.getParameter("id");
    String panelName = request.getParameter("panelname");
    PagePanel panel = pagePanelService.findPagePanel(panelName);
    SystemMainTable smt = panel.getSystemMainTable();
    String tableName = smt.getTableName();
    String className = smt.getClassName();
    Class clazz = null;
    try {
      clazz = Class.forName(className);
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    List<PagePanelColumn> pagePanelColumns = pageManager.getUserPagePanelColumn(panelName);

    Map<String, Object> dataMap = null;
    if (StringUtils.isNotBlank(id)) {
      if (panel.getXtype().getName().equals("form")) {
        Object obj = service.find(clazz, id, true);
        dataMap = metaDataManager.getEntityDataForEdit(obj, tableName);
        json = CoderForSave.encode(pagePanelColumns, dataMap, true);

      } else {
        json = null;
      }

    } else {
      dataMap = pageManager.getPagePanelDataForAdd(panelName);
      json = CoderForSave.encode(pagePanelColumns, dataMap, false);
    }

    return json;
  }
Esempio n. 2
0
  /**
   * 保存使用的元数据 @Methods Name forSave @Create In Sep 9, 2008 By yang
   *
   * @param request
   * @return @ReturnType String
   */
  private String forSave(HttpServletRequest request) {
    String json = "";
    String id = request.getParameter("id");

    String modelName = request.getParameter("modelname");
    String panelName = request.getParameter("panelname");
    PagePanel panel = pagePanelService.findPagePanel(panelName);
    List<PagePanelColumn> pagePanelColumns = pageManager.getUserPagePanelColumn(panelName);

    Map<String, Object> dataMap = null;
    if (StringUtils.isNotBlank(id)) {
      List<Map<String, Object>> listMap = null;
      // 此代码有问题应该用下面的
      // listMap = configItemService.getRequireCIDataForEdit(modelName, panelName, id);
      //			}else{
      listMap = pageManager.getPagePanelDataForEdit(modelName, panelName, id);
      //			}

      if (listMap != null && !listMap.isEmpty()) {
        if (panel.getXtype().getName().equals("form")) {
          dataMap = listMap.iterator().next();
          String webContext = request.getContextPath();
          dataMap.put("webContext", webContext);
          json = CoderForSave.encode(pagePanelColumns, dataMap, true);

        } else if (panel.getXtype().getName().equals("editorgrid")) {
          int total = listMap.size();
          json = CoderForList.encode(pagePanelColumns, listMap, Long.valueOf(total));
        }
      }

    } else {
      dataMap = pageManager.getPagePanelDataForAdd(panelName);
      json = CoderForSave.encode(pagePanelColumns, dataMap, false);
    }

    return json;
  }