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);
         }
       }
     }
   }
 }
 /**
  * 表格数据验证
  *
  * @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;
       }
     }
   }
 }