示例#1
0
 private void validate(Dataset ds) {
   UIPartMeta uimeta = AppSession.current().getViewContext().getUIMeta();
   ViewPartMeta widget = AppSession.current().getViewContext().getView();
   ViewPartComps vc = widget.getViewComponents();
   if (vc != null) {
     WebComp[] wcs = vc.getComps();
     if (wcs != null && wcs.length > 0) {
       // 筛选Form和Gird,排序Form在前,Grid在后
       List<WebComp> comps = new ArrayList<WebComp>();
       for (WebComp wc : wcs) {
         if (uimeta.findChildById(wc.getId()) == null) { // 当前控件未被使用
           continue;
         }
         if (wc instanceof FormComp && ds.getId().equals(((FormComp) wc).getDataset())) {
           comps.add(0, wc);
         } else if (wc instanceof GridComp && ds.getId().equals(((GridComp) wc).getDataset())) {
           comps.add(wc);
         }
       }
       for (WebComp wc : comps) {
         if (wc instanceof FormComp) {
           validate(ds, (FormComp) wc);
         } else if (wc instanceof GridComp) {
           validate(ds, (GridComp) wc);
         }
       }
     }
   }
 }
示例#2
0
 /** 验证片段 */
 public void validate(Dataset ds, ViewPartMeta widget) {
   // 如果传入的片段为空 验证数据集
   if (widget == null || widget.getId() == null) {
     validate(ds);
   } else {
     // 否则以form和grid中设置的为准
     WebComp[] comps = widget.getViewComponents().getComps();
     if (comps != null && comps.length > 0) {
       for (WebComp comp : comps) {
         if (comp instanceof IDataBinding) {
           IDataBinding dbcomp = (IDataBinding) comp;
           if (ds.getId().equals(dbcomp.getDataset())) {
             validate(ds, dbcomp);
           }
         }
       }
     }
   }
   showValidateInOldStyle(ds);
 }
示例#3
0
 /**
  * 表格数据验证
  *
  * @param ds
  * @param gridcomp
  */
 public void validate(Dataset ds, GridComp gc) {
   if (gc != null) {
     // 隐藏整体错误提示框
     gc.hideErrorMsg();
     List<IGridColumn> columns = gc.getColumnList();
     if (columns != null && columns.size() > 0) {
       Field field = null;
       for (IGridColumn colum : columns) {
         if (colum instanceof GridColumn) {
           field = ds.getField(((GridColumn) colum).getField());
           if (field != null && field.isRequire()) { // field存在并且允许为空,则取gridColumn的非空校验规则.
             field.setRequire(((GridColumn) colum).isRequire());
           }
         }
       }
     }
   }
   Map<String, Object> validatorMap = validator(ds);
   if (validatorMap == null) {
     return;
   }
   validatorMap = dealValidator(validatorMap, ds);
   // 所有错误信息 key-fieldid value-errorMsg
   Map<String, String> error_fields_map =
       (Map<String, String>) validatorMap.get("error_fields_map");
   if (error_fields_map != null && !error_fields_map.isEmpty()) {
     UIPartMeta uimeta = AppSession.current().getViewContext().getUIMeta();
     ViewPartMeta widget = AppSession.current().getViewContext().getView();
     ViewPartComps vc = widget.getViewComponents();
     if (gc != null
         && uimeta.findChildById(gc.getId()) != null
         && ds.getId().equals((gc.getDataset()))) {
       // 错误标题序号
       int index = 1;
       StringBuffer allErrorMsg =
           new StringBuffer(Validator.getValidatorMsg(ValidatorType.saveFailure.ordinal()));
       // 平台默认验证-错误信息分类
       Map<Integer, List<Field>> type_fields_map =
           (Map<Integer, List<Field>>) validatorMap.get("type_fields_map");
       if (type_fields_map != null && !type_fields_map.isEmpty()) {
         List<Field> list = null;
         ValidatorType[] types = ValidatorType.values();
         for (ValidatorType type : types) {
           list = type_fields_map.get(type.ordinal());
           if (list != null && list.size() > 0) {
             index =
                 getFieldErrorMsgByErrorType(
                     allErrorMsg,
                     list,
                     gc,
                     index,
                     Validator.getValidatorMsg(ValidatorType.followingMsg.ordinal())
                         + Validator.getValidatorMsg(type.ordinal())
                         + ":");
           }
         }
       }
       // 自定义公式验证-错误信息分类
       Map<String, List<Field>> formular_fields_map =
           (Map<String, List<Field>>) validatorMap.get("formular_fields_map");
       if (formular_fields_map != null && !formular_fields_map.isEmpty()) {
         List<Field> list = null;
         String key = null;
         Iterator<String> keys = formular_fields_map.keySet().iterator();
         while (keys.hasNext()) {
           key = keys.next();
           list = formular_fields_map.get(key);
           if (list != null && list.size() > 0) {
             index = getFieldErrorMsgByErrorType(allErrorMsg, list, gc, index, key + ":");
           }
         }
       }
       if (index > 1) {
         LuiValidateException exception = new LuiValidateException(allErrorMsg.toString());
         exception.setViewId(widget.getId());
         exception.addComponentId(gc.getId());
         exception.setElementMap(error_fields_map);
         throw exception;
       }
     }
   }
 }
示例#4
0
  public SigTabPopUpOper(Map<String, String> map) {

    files = new CommBaseCreateFile(map);
    PagePartMeta pagePartMeta = files.getPagePartMeta();
    ViewPartMeta viewPartMeta = files.getMapViewPartMeta().get("main");

    LifeCyclePhase phase = RequestLifeCycleContext.get().getPhase();
    RequestLifeCycleContext.get().setPhase(LifeCyclePhase.nullstatus);
    SigTabCardOper sigTabCardOper = new SigTabCardOper();

    DatasetConfExpand datasetConf = sigTabCardOper.getDatasetConf(map, viewPartMeta);
    String dsId = datasetConf.getDsId();

    AddMdDataSetToViewPartMeta(datasetConf);
    map.put("masterKey", datasetConf.getMasterKey());
    String uiLayoutType = (String) map.get("uiLayoutType");
    if (StringUtils.equals(uiLayoutType, "UiSigTabPopUpLayout")) {
      sigTabLayout = new UiSigTabPopUpLayout();
    } else if (StringUtils.equals(uiLayoutType, "UiParChiTabPopUpFullLayout")
        || StringUtils.equals(uiLayoutType, "UiParChiTabPopUpPopUpLayout")) {
      sigTabLayout = new UiParChiTabPopUpFullLayout();
    } else if (StringUtils.equals(uiLayoutType, "UiTreeTabPopUpLayout")) {
      sigTabLayout = new UiTreeTabPopUpLayout();
    } else if (StringUtils.equals(uiLayoutType, "UiTreeTabTabPopUpFullLayout")
        || StringUtils.equals(uiLayoutType, "UiTreeTabTabPopUpPopUpLayout")) {
      sigTabLayout = new UiTreeTabTabPopUpFullLayout();
    } else if (StringUtils.equals(uiLayoutType, "UiParChiTabPopUpCardLayout")) {
      sigTabLayout = new UiParChiTabPopUpCardLayout();
    } else if (StringUtils.equals(uiLayoutType, "UiTreeTabTabPopUpCardLayout")) {
      sigTabLayout = new UiTreeTabTabPopUpCardLayout();
    }

    String ctrlId =
        addCtrlToViewPartMeta(
            files.getPagePartMeta(), viewPartMeta, dsId, SigTabCardOper.ctrlType_ToolBarComp);
    sigTabLayout.getToolBar().setId(ctrlId); // 布局ToolBar
    toolBarComp = (ToolBarComp) viewPartMeta.getViewComponents().getComponent(ctrlId);

    ctrlId =
        addCtrlToViewPartMeta(
            files.getPagePartMeta(), viewPartMeta, dsId, SigTabCardOper.ctrlType_GridComp);
    sigTabLayout.getGridComp_Par().setId(ctrlId); // 布局表格
    files.getMapViewUiPartMeta().get("main").setElement(sigTabLayout.getLayoutMain());

    // 配置 toolBarItem的点击事件
    String controller = viewPartMeta.getController();
    Map<String, String> map_TBPara = new HashMap<String, String>();
    map_TBPara.put("controller", controller);
    map_TBPara.put("dsId", map.get("dsId"));
    map_TBPara.put("viewId", parTabEditView_Id);
    setEventConf_sigTabPopUpToolBar(toolBarComp, map_TBPara);
    {
      files._new_view(parTabEditView_Id, "");
      ViewPartMeta parTabEditViewPartMeta =
          files.getMapViewPartMeta().get(parTabEditView_Id); // 树编辑的ViewPartMeta
      UIPartMeta parTabEditViewUIPartMeta =
          files.getMapViewUiPartMeta().get(parTabEditView_Id); // 树编辑的UIPartMeta
      UiCtrlEditLayout parTabEditLayout = new UiCtrlEditLayout(); // 树的编辑弹出框布局对象
      parTabEditViewUIPartMeta.setElement(parTabEditLayout.getLayoutMain()); // 将布局对象添加到layout.xml里
      DatasetConfExpand datasetConf_ParTab =
          sigTabCardOper.getDatasetConf(map, parTabEditViewPartMeta);
      datasetConf_ParTab.setIsAfterSelRowEvent(false);

      dsId = datasetConf_ParTab.getDsId();
      datasetConf.setIsNORelation(true);
      AddMdDataSetToViewPartMeta(datasetConf_ParTab);
      { // 重新配置 parTabEditView 的onload事件
        String operDsId = map.get("dsId");
        setEventConf_AddOrEditBeforeShow(parTabEditViewPartMeta, operDsId);
      }
      String formCompId =
          addCtrlToViewPartMeta(
              pagePartMeta, parTabEditViewPartMeta, dsId, SigTabCardOper.ctrlType_FormComp);
      parTabEditLayout.getFormComp().setId(formCompId);

      String buttonSaveId =
          addCtrlToViewPartMeta(
              pagePartMeta, parTabEditViewPartMeta, editView_btnSaveId, ctrlType_ButtonComp);
      {
        Map<String, String> map_btn = new HashMap<String, String>();
        map_btn.put("dsId", map.get("dsId"));
        map_btn.put("btnId", buttonSaveId);
        setEventConf_Par_PopUpWinButtonSave(parTabEditViewPartMeta, map_btn);
      }
      String buttonCancelId =
          addCtrlToViewPartMeta(
              pagePartMeta, parTabEditViewPartMeta, editView_btnCancelId, ctrlType_ButtonComp);
      {
        Map<String, String> map1 = new HashMap<String, String>();
        map1.put("viewId", parTabEditView_Id);
        map1.put("btnId", buttonCancelId);
        setEventConf_PopUpWinButtonCancel(parTabEditViewPartMeta, map1);
      }
    }

    RequestLifeCycleContext.get().setPhase(phase);
  }