Search in sources :

Example 6 with ParamConfigBean

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

the class MyValidatorImpl method create.

public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
        return null;
    Class<?> clazz = this.ann.clazz();
    String valName = clazz.getSimpleName();
    if (val == null || !valName.equals(val.getName())) {
        val = new ValidatorConfigBean();
        val.setName(valName);
        val.setClazz(clazz.getName());
    }
    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
    fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
    String[] params = ann.params();
    String[] values = ann.values();
    if (params.length > 0 && values.length > 0 && params.length == values.length) {
        for (int i = 0; i < params.length; i++) {
            ParamConfigBean pcb = new ParamConfigBean();
            pcb.setName(CommonUtil.parsePropValue(params[i]));
            pcb.setValue(CommonUtil.parsePropValue(values[i]));
            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 7 with ParamConfigBean

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

the class RegexImpl method create.

public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
        return null;
    if (val == null || !Validators.REGEX.equals(val.getName())) {
        val = new ValidatorConfigBean();
        val.setName(Validators.REGEX);
    }
    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
    fcb.setMessage(CommonUtil.parsePropValue(ann.mess()));
    ParamConfigBean pcb = new ParamConfigBean();
    pcb.setName(Validators.REGEX_PARAM);
    pcb.setValue(CommonUtil.parsePropValue(ann.pattern()));
    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 8 with ParamConfigBean

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

the class ActionSupport method init.

public ActionSupport init(HttpServletRequest request, HttpServletResponse response, ActionConfigBean configBean) throws Exception {
    this.request = request;
    this.response = response;
    this.configBean = configBean;
    this.param = new HashMap<String, String>();
    if (this.configBean != null) {
        List<ParamConfigBean> pList = this.configBean.getParam();
        if (pList != null) {
            for (ParamConfigBean p : pList) {
                this.param.put(p.getName(), p.getValue());
            }
        }
    }
    return this;
}
Also used : ParamConfigBean(org.eweb4j.mvc.config.bean.ParamConfigBean)

Example 9 with ParamConfigBean

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

the class UploadImpl method create.

public ValidatorConfigBean create(String fieldName, ValidatorConfigBean val) {
    if (this.ann == null)
        return null;
    if (val == null || !Validators.UPLOAD.equals(val.getName())) {
        val = new ValidatorConfigBean();
        val.setName(Validators.UPLOAD);
    }
    FieldConfigBean fcb = new FieldConfigBean();
    fcb.setName(fieldName);
    ParamConfigBean suffix = new ParamConfigBean();
    suffix.setName(Validators.UPLOAD_SUFFIX);
    StringBuilder sb = new StringBuilder();
    for (String s : ann.suffix()) {
        if (sb.length() > 0)
            sb.append(",");
        sb.append(CommonUtil.parsePropValue(s));
    }
    suffix.setValue(sb.toString());
    fcb.getParam().add(suffix);
    ParamConfigBean suffixMsg = new ParamConfigBean();
    suffixMsg.setName(Validators.UPLOAD_SUFFIX_MSG);
    suffixMsg.setValue(CommonUtil.parsePropValue(ann.msg().suffix()));
    fcb.getParam().add(suffixMsg);
    ParamConfigBean maxFileSize = new ParamConfigBean();
    maxFileSize.setName(Validators.UPLOAD_MAX_FILE_SIZE);
    maxFileSize.setValue(CommonUtil.parsePropValue(ann.maxFileSize()));
    fcb.getParam().add(maxFileSize);
    ParamConfigBean maxFileSizeMsg = new ParamConfigBean();
    maxFileSizeMsg.setName(Validators.UPLOAD_MAX_FILE_SIZE_MSG);
    maxFileSizeMsg.setValue(CommonUtil.parsePropValue(ann.msg().maxFileSize()));
    fcb.getParam().add(maxFileSizeMsg);
    ParamConfigBean maxMemorySize = new ParamConfigBean();
    maxMemorySize.setName(Validators.UPLOAD_MAX_MEMORY_SIZE);
    maxMemorySize.setValue(CommonUtil.parsePropValue(ann.maxMemorySize()));
    fcb.getParam().add(maxMemorySize);
    ParamConfigBean maxMemorySizeMsg = new ParamConfigBean();
    maxMemorySizeMsg.setName(Validators.UPLOAD_MAX_MEMORY_SIZE_MSG);
    maxMemorySizeMsg.setValue(CommonUtil.parsePropValue(ann.msg().maxMemorySize()));
    fcb.getParam().add(maxMemorySizeMsg);
    ParamConfigBean maxRequestSize = new ParamConfigBean();
    maxRequestSize.setName(Validators.UPLOAD_MAX_REQ_SIZE);
    maxRequestSize.setValue(CommonUtil.parsePropValue(ann.maxRequestSize()));
    fcb.getParam().add(maxRequestSize);
    ParamConfigBean maxRequestSizeMsg = new ParamConfigBean();
    maxRequestSizeMsg.setName(Validators.UPLOAD_MAX_REQ_SIZE_MSG);
    maxRequestSizeMsg.setValue(CommonUtil.parsePropValue(ann.msg().maxRequestSize()));
    fcb.getParam().add(maxRequestSizeMsg);
    ParamConfigBean tmpDir = new ParamConfigBean();
    tmpDir.setName(Validators.UPLOAD_TMP_DIR);
    tmpDir.setValue(CommonUtil.parsePropValue(ann.tmpDir()));
    fcb.getParam().add(tmpDir);
    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 10 with ParamConfigBean

use of org.eweb4j.mvc.config.bean.ParamConfigBean 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)

Aggregations

ParamConfigBean (org.eweb4j.mvc.config.bean.ParamConfigBean)20 FieldConfigBean (org.eweb4j.mvc.config.bean.FieldConfigBean)19 ValidatorConfigBean (org.eweb4j.mvc.config.bean.ValidatorConfigBean)11 HashMap (java.util.HashMap)8 Validation (org.eweb4j.mvc.action.Validation)8 ActionConfigBean (org.eweb4j.mvc.config.bean.ActionConfigBean)2 ResultConfigBean (org.eweb4j.mvc.config.bean.ResultConfigBean)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 ConfigBean (org.eweb4j.config.bean.ConfigBean)1 LogConfigBean (org.eweb4j.config.bean.LogConfigBean)1 IOCConfigBean (org.eweb4j.ioc.config.bean.IOCConfigBean)1 InterConfigBean (org.eweb4j.mvc.config.bean.InterConfigBean)1 UploadFile (org.eweb4j.mvc.upload.UploadFile)1 ORMConfigBean (org.eweb4j.orm.config.bean.ORMConfigBean)1 DBInfoConfigBean (org.eweb4j.orm.dao.config.bean.DBInfoConfigBean)1