Search in sources :

Example 16 with ValidatorConfigBean

use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.

the class MVCConfigBeanCreator method getActionBean.

public static ActionConfigBean getActionBean() {
    ActionConfigBean mvcBean = null;
    mvcBean = new ActionConfigBean();
    List<ResultConfigBean> rlist = new ArrayList<ResultConfigBean>();
    ResultConfigBean result = new ResultConfigBean();
    rlist.add(result);
    mvcBean.setResult(rlist);
    List<ValidatorConfigBean> vlist = new ArrayList<ValidatorConfigBean>();
    ValidatorConfigBean validator = new ValidatorConfigBean();
    List<FieldConfigBean> fieldList = new ArrayList<FieldConfigBean>();
    FieldConfigBean field = new FieldConfigBean();
    List<ParamConfigBean> paramList = new ArrayList<ParamConfigBean>();
    ParamConfigBean param = new ParamConfigBean();
    paramList.add(param);
    field.setParam(paramList);
    fieldList.add(field);
    validator.setField(fieldList);
    vlist.add(validator);
    mvcBean.setValidator(vlist);
    mvcBean.setParam(paramList);
    return mvcBean;
}
Also used : ValidatorConfigBean(org.eweb4j.mvc.config.bean.ValidatorConfigBean) ParamConfigBean(org.eweb4j.mvc.config.bean.ParamConfigBean) FieldConfigBean(org.eweb4j.mvc.config.bean.FieldConfigBean) ResultConfigBean(org.eweb4j.mvc.config.bean.ResultConfigBean) ArrayList(java.util.ArrayList) ActionConfigBean(org.eweb4j.mvc.config.bean.ActionConfigBean)

Example 17 with ValidatorConfigBean

use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.

the class ChineseImpl method create.

public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
        return null;
    if (val == null || !Validators.CHINESE.equals(val.getName())) {
        val = new ValidatorConfigBean();
        val.setName(Validators.CHINESE);
    }
    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
    fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
    val.getField().add(fcb);
    return val;
}
Also used : ValidatorConfigBean(org.eweb4j.mvc.config.bean.ValidatorConfigBean) FieldConfigBean(org.eweb4j.mvc.config.bean.FieldConfigBean)

Example 18 with ValidatorConfigBean

use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.

the class DateImpl method create.

public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
        return null;
    if (val == null || !Validators.DATE.equals(val.getName())) {
        val = new ValidatorConfigBean();
        val.setName(Validators.DATE);
    }
    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
    fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
    ParamConfigBean pcb = new ParamConfigBean();
    pcb.setName(Validators.DATE_FORMAT_PARAM);
    pcb.setValue(CommonUtil.parsePropValue(ann.value()));
    fcb.getParam().add(pcb);
    val.getField().add(fcb);
    return val;
}
Also used : ValidatorConfigBean(org.eweb4j.mvc.config.bean.ValidatorConfigBean) ParamConfigBean(org.eweb4j.mvc.config.bean.ParamConfigBean) FieldConfigBean(org.eweb4j.mvc.config.bean.FieldConfigBean)

Example 19 with ValidatorConfigBean

use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.

the class EnumImpl method create.

public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
        return null;
    if (val == null || !Validators.ENUM.equals(val.getName())) {
        val = new ValidatorConfigBean();
        val.setName(Validators.ENUM);
    }
    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
    fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
    ParamConfigBean pcb = new ParamConfigBean();
    pcb.setName(Validators.ENUM_WORD_PARAM);
    StringBuilder sb = new StringBuilder();
    for (String s : ann.words()) {
        if (sb.length() > 0)
            sb.append("#");
        sb.append(CommonUtil.parsePropValue(s));
    }
    pcb.setValue(sb.toString());
    fcb.getParam().add(pcb);
    val.getField().add(fcb);
    return val;
}
Also used : ValidatorConfigBean(org.eweb4j.mvc.config.bean.ValidatorConfigBean) ParamConfigBean(org.eweb4j.mvc.config.bean.ParamConfigBean) FieldConfigBean(org.eweb4j.mvc.config.bean.FieldConfigBean)

Example 20 with ValidatorConfigBean

use of org.eweb4j.mvc.config.bean.ValidatorConfigBean in project eweb4j-framework by laiweiwei.

the class EqualsImpl method create.

public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
        return null;
    if (val == null || !Validators.EQUALS.equals(val.getName())) {
        val = new ValidatorConfigBean();
        val.setName(Validators.EQUALS);
    }
    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
    fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
    ParamConfigBean pcb = new ParamConfigBean();
    pcb.setName(Validators.EQUALS_TO_PARAM);
    String value = CommonUtil.parsePropValue(ann.to());
    value = fieldName.substring(0, fieldName.lastIndexOf(".") + 1) + value;
    pcb.setValue(value);
    fcb.getParam().add(pcb);
    val.getField().add(fcb);
    return val;
}
Also used : ValidatorConfigBean(org.eweb4j.mvc.config.bean.ValidatorConfigBean) ParamConfigBean(org.eweb4j.mvc.config.bean.ParamConfigBean) FieldConfigBean(org.eweb4j.mvc.config.bean.FieldConfigBean)

Aggregations

ValidatorConfigBean (org.eweb4j.mvc.config.bean.ValidatorConfigBean)25 FieldConfigBean (org.eweb4j.mvc.config.bean.FieldConfigBean)21 ParamConfigBean (org.eweb4j.mvc.config.bean.ParamConfigBean)11 ArrayList (java.util.ArrayList)3 ActionConfigBean (org.eweb4j.mvc.config.bean.ActionConfigBean)3 ResultConfigBean (org.eweb4j.mvc.config.bean.ResultConfigBean)2 Annotation (java.lang.annotation.Annotation)1 Field (java.lang.reflect.Field)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ConfigBean (org.eweb4j.config.bean.ConfigBean)1 LogConfigBean (org.eweb4j.config.bean.LogConfigBean)1 IOCConfigBean (org.eweb4j.ioc.config.bean.IOCConfigBean)1 Validation (org.eweb4j.mvc.action.Validation)1 Result (org.eweb4j.mvc.action.annotation.Result)1 InterConfigBean (org.eweb4j.mvc.config.bean.InterConfigBean)1 Skip (org.eweb4j.mvc.validator.annotation.Skip)1 Validate (org.eweb4j.mvc.validator.annotation.Validate)1 ORMConfigBean (org.eweb4j.orm.config.bean.ORMConfigBean)1 DBInfoConfigBean (org.eweb4j.orm.dao.config.bean.DBInfoConfigBean)1