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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations