【form.vm 用于生成自定义表单的前台界面及验证逻辑】
#* @vtlvariable name="javatype" type="CodeGen.customModel.util.JavaDataType" *### #* @vtlvariable name="displaytype" type="CodeGen.customModel.util.DisplayType" *### #* @vtlvariable name="formInfo" type="CodeGen.customModel.util.FormInfo" *### #* @vtlvariable name="StrWrapper" type="Easis.Common.StringUtilWrapper" *### #* @vtlvariable name="ruletype" type="CodeGen.customModel.util.ValidateRuleType" *### <%@ page contentType="text/html;charset=UTF-8" language="java" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> 自定义表单: $formInfo.getChineseName(); </title> <link href="/content/dtcms/style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="/content/scripts/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="/content/scripts/jquery.cookie.js"></script> <script type="text/javascript" src="/content/scripts/framework.js"></script> <!--弹出窗口插件--> <link rel="stylesheet" href="/content/UI/artDialog/skins/chrome.css" /> <script type="text/javascript" src="/content/UI/artDialog/artDialog.js"></script> <script type="text/javascript" src="/content/UI/artDialog/index.js"></script> <!--表单验证--> <link rel="stylesheet" href="/content/UI/validation/index.css"/> <script type="text/javascript" src="/content/UI/validation/validation.js"></script> <script type="text/javascript" src="/content/UI/validation/index.js"></script> <!--编辑器--> <script charset="utf-8" src="/content/UI/editor/kindeditor/kindeditor-min.js"></script> <script charset="utf-8" src="/content/UI/editor/kindeditor/lang/zh_CN.js"></script> <script type="text/javascript" src="/content/UI/editor/index.js"></script> <!--日期--> <script language="javascript" type="text/javascript" src="/content/UI/dataPicker/WdatePicker.js"></script> <!--邮箱自动提示--> <script type="text/javascript" src="/content/UI/mailTip/jquery.mailtip.js"></script> <link type="text/css" rel="stylesheet" href="/content/UI/mailTip/mailtip.css"/> <!--颜色选择器--> <script type="text/javascript" src="/content/UI/jsColor/jscolor.js"></script> </head> <body class="mainbody"> <script type="text/javascript"> //===========================系统管理JS函数开始================================ //Tab控制函数 function tabs(tabId, tabNum) { //设置点击后的切换样式 jQuery(tabId + " .tab_nav li").removeClass("selected"); jQuery(tabId + " .tab_nav li").eq(tabNum).addClass("selected"); //根据参数决定显示内容 jQuery(tabId + " .tab_con").hide(); jQuery(tabId + " .tab_con").eq(tabNum).show(); } </script> <form id="$formInfo.formID"> <div class="navigation"><a href="javascript:history.go(-1);" class="back">后退</a> <a href="javascript:location.reload();" class="refresh">刷新</a>首页 > 【自定义表单】 > 【$formInfo.getChineseName()】</div> <div id="contentTab"> <ul class="tab_nav"> <li class="selected"><a onclick="tabs('#contentTab',0);" href="javascript:;">基本信息</a></li> <li><a onclick="tabs('#contentTab',1);" href="javascript:;">选填</a></li> <!-- <li><a onclick="tabs('#contentTab',2);" href="javascript:;">SEO选项</a></li>--> </ul> <div class="tab_con" style="display:block;"> <table class="form_table"> <col width="150px"><input type="hidden" name="" value="0"/><col> <tbody> #foreach($litem1 in $formInfo.getParameterList()) #*开始生成UI*# #if($litem1.getDisplayType().equals($displaytype.getInputNormalText())) <tr> <th>$litem1.name_ZH:</th> <td> <input id="txt_$litem1.parameterName" type="text" class="txtInput normal" name="$formInfo.prefix$litem1.parameterName" value="" /> <span id="tips_$litem1.parameterName"></span> </td> </tr> #elseif($litem1.getDisplayType().equals($displaytype.getCheckbox_Boolean())) <tr> <th>$litem1.name_ZH:</th> <td> <input type="checkbox" name="$formInfo.prefix$litem1.parameterName" id="txt_$litem1.parameterName" value="1"/> <span id="tips_$litem1.parameterName"></span> </td> </tr> #elseif($litem1.getDisplayType().equals($displaytype.getRadio_Boolean())) <tr> <th>$litem1.name_ZH:</th> <td> <input type="radio" name="$formInfo.prefix$litem1.parameterName" value="1"/>是 <input type="radio" name="$formInfo.prefix$litem1.parameterName" value="0"/>否 <span id="tips_$litem1.parameterName"></span> </td> </tr> #elseif($litem1.getDisplayType().equals($displaytype.getInputColorPicker())) <tr> <th>$litem1.name_ZH:</th> <td> <input id="txt_$litem1.parameterName" type="text" class="txtInput normal color" name="$formInfo.prefix$litem1.parameterName" value="" /> <span id="tips_$litem1.parameterName"></span> </td> </tr> #elseif($litem1.getDisplayType().equals($displaytype.inputDateTimePicker)) <tr> <th>$litem1.name_ZH:</th> <td> <input id="txt_$litem1.parameterName" type="text" class="txtInput normal" name="$formInfo.prefix$litem1.parameterName" value="" onClick="WdatePicker()" /> <span id="tips_$litem1.parameterName"></span> </td> </tr> #elseif($litem1.getDisplayType().equals($displaytype.inputEmailText)) <tr> <th>$litem1.name_ZH:</th> <td> <input id="txt_$litem1.parameterName" type="text" class="txtInput normal" name="$formInfo.prefix$litem1.parameterName" value="" /> <span id="tips_$litem1.parameterName"></span> <script type="text/javascript"> jQuery(function (){ jQuery('\#txt_$litem1.getParameterName()').mailtip({ afterselect: function (mail){ } }); }); </script> </td> </tr> #elseif($litem1.getDisplayType().equals($displaytype.inputFileURL)) <tr> <th>$litem1.getName_ZH():</th> <td> <input id="txt_$litem1.getParameterName()" type="text" class="txtInput normal" > <input type="button" class="btnSearch" id="btn_upload_$litem1.getParameterName()" value="打开文件"/> <span id="tips_$litem1.getParameterName()"></span> <script type="text/javascript"> KindEditor.ready(function(K) { var editor_$litem1.getParameterName() = K.editor({ uploadJson: '/tools/kindeditor/upload.jsp', fileManagerJson: '/tools/kindeditor/filemanager.jsp', allowFileManager : true }); K('#btn_upload_$litem1.getParameterName()').click(function() { editor_${litem1.getParameterName()}.loadPlugin('insertfile', function() { editor_${litem1.getParameterName()}.plugin.fileDialog({ fileUrl : K('#txt_$litem1.getParameterName()').val(), clickFn : function(url, title) { K('#txt_$litem1.getParameterName()').val(url); editor_${litem1.getParameterName()}.hideDialog(); } }); }); }); }); </script> </td> </tr> #elseif($litem1.getDisplayType().equals($displaytype.inputHiddenField)) <tr> <th>$litem1.name_ZH:</th> <td> <input id="txt_$litem1.parameterName" type="hidden" class="txtInput normal" name="$formInfo.prefix$litem1.parameterName" value="" /> 【该参数被隐藏】 </td> </tr> #elseif($litem1.getDisplayType().equals($displaytype.inputImgURL)) <tr> <th>$litem1.getName_ZH():</th> <td> <input id="txt_$litem1.getParameterName()" type="text" class="txtInput normal" > <input type="button" class="btnSearch" id="btn_upload_$litem1.getParameterName()" value="上传图片"/> <span id="tips_$litem1.getParameterName()"></span> <script type="text/javascript"> KindEditor.ready(function(K) { var editor_$litem1.getParameterName() = K.editor({ uploadJson: '/tools/kindeditor/upload.jsp', fileManagerJson: '/tools/kindeditor/filemanager.jsp', allowFileManager : true }); K('#btn_upload_$litem1.getParameterName()').click(function() { editor_${litem1.getParameterName()}.loadPlugin('image', function() { editor_${litem1.getParameterName()}.plugin.imageDialog({ imageUrl : K('#txt_$litem1.getParameterName()').val(), clickFn : function(url, title, width, height, border, align) { K('#txt_$litem1.getParameterName()').val(url); editor_$litem1.getParameterName().hideDialog(); } }); }); }); }); </script> </td> </tr> #elseif($litem1.getDisplayType().equals($displaytype.inputRichEditor)) <tr> <th>$litem1.getName_ZH():</th> <td> <textarea id="txt_$litem1.getParameterName()" name="$formInfo.prefix$litem1.getParameterName()" style="width:800px;height:400px;visibility:hidden;">请填写内容</textarea> <span id="tips_$litem1.getParameterName()"></span> <script type="text/javascript"> var editor_$litem1.getParameterName()=new Editor(); editor_${litem1.getParameterName()}.createEditor("#txt_$litem1.getParameterName()"); </script> </td> </tr> #else <tr> <th>$litem1.name_ZH:</th> <td> <input id="txt_$litem1.parameterName" type="text" class="txtInput normal" name="$formInfo.prefix$litem1.parameterName" value="" /> <span id="tips_$litem1.parameterName"></span> </td> </tr> #end #*生成UI结束*# #end </tbody> </table> </div> <div class="tab_con"> <table class="form_table"> <col width="150px"><col> <tbody> <!-- <tr> <th>真实名称:</th> <td> <input id="txt_realName" type="text" class="txtInput normal" name="model.realName" value="" /> <span id="tips_realName">*</span> </td> </tr> <tr> <th>手机号码:</th> <td> <input id="txt_mobile" type="text" class="txtInput normal" name="model.mobile" value="" /> <span id="tips_mobile">*</span> </td> </tr> --> </tbody> </table> </div> <!-- <div class="tab_con"> <table class="form_table"> <col width="150px"><col> <tbody> </tbody> </table> </div>--> <div class="foot_btn_box"> <input type="button" name="btnSubmit" value="提交保存" id="btnSubmit_$formInfo.getFormID()" class="btnSubmit" /> <input name="重置" type="reset" class="btnSubmit" value="重 置" /> </div> </div> <div class="line10"></div> </form> <script type="text/javascript"> var myv=new Validation(); function checkparas() { var isAllow = true; //--所有数据的验证 #foreach($litem1 in $formInfo.parameterList) #*首先,隐藏参数,radio,checkbox这些都是不用验证的*# #if($litem1.getDisplayType().equals($displaytype.inputHiddenField)||$litem1.getDisplayType().equals($displaytype.checkbox_Boolean)||$litem1.getDisplayType().equals($displaytype.radio_Boolean)) /*${litem1.getParameterName()}({$litem1.getName_ZH()})),类型:【$litem1.getDisplayType()】,无须验证*/ var tips_$litem1.getParameterName()=jQuery("\#tips_$litem1.getParameterName()"); SetSuccessTips(tips_$litem1.getParameterName(),""); #*其次,rich text editor只能验证是否必须填写---因为既然都让人写html了,还验证什么。*# #elseif($litem1.getDisplayType().equals($displaytype.inputRichEditor)) editor_${litem1.getParameterName()}.sync(); var str_$litem1.getParameterName()=editor_${litem1.getParameterName()}.getText(); var tips_$litem1.getParameterName()=jQuery("\#tips_$litem1.getParameterName()"); SetSuccessTips(tips_$litem1.getParameterName(),""); #*遍历规则*# #foreach($litem2 in $litem1.validatelist) #if($litem2.validateRuleType.equals($ruletype.getRule_isRequired())) if(myv.isRequired(str_$litem1.getParameterName())==false){ isAllow=false; SetErrorTips(tips_$litem1.getParameterName(),"$litem2.getErrorMessage()"); } #end #end ##对于上传图片及上传文件来及URL,只需要验证是否必须及是否为url #elseif($litem1.getDisplayType().equals($displaytype.inputFileURL)||$litem1.getDisplayType().equals($displaytype.inputImgURL)) var str_$litem1.getParameterName()=jQuery.trim(jQuery("\#txt_$litem1.getParameterName()").text()); var tips_$litem1.getParameterName()=jQuery("\#tips_$litem1.getParameterName()"); SetSuccessTips(tips_$litem1.getParameterName(),""); if(myv.isURL(str_$litem1.getParameterName())==false){ SetErrorTips(tips_$litem1.getParameterName(),"$litem1.getName_ZH()格式错误!"); isAllow=false; } #*遍历规则*# #foreach($litem2 in $litem1.validatelist) #if($litem2.validateRuleType.equals($ruletype.getRule_isRequired())) if(myv.isRequired(str_$litem1.getParameterName())==false){ isAllow=false; SetErrorTips(tips_$litem1.getParameterName(),"$litem2.getErrorMessage()"); } #end #end ##图片上传文件上传验证结束 ##对于邮箱而言只需要验证邮箱格式 #elseif($litem1.getDisplayType().equals($displaytype.inputEmailText)) var str_$litem1.getParameterName()=jQuery.trim(jQuery("\#txt_$litem1.getParameterName()").text()); var tips_$litem1.getParameterName()=jQuery("\#tips_$litem1.getParameterName()"); SetSuccessTips(tips_$litem1.getParameterName(),""); if(myv.isEmailAddr(str_$litem1.getParameterName())==false){ SetErrorTips(tips_$litem1.getParameterName(),"$litem1.getName_ZH()格式错误!"); isAllow=false; } #*遍历规则*# #foreach($litem2 in $litem1.validatelist) #if($litem2.validateRuleType.equals($ruletype.getRule_isRequired())) if(myv.isRequired(str_$litem1.getParameterName())==false){ isAllow=false; SetErrorTips(tips_$litem1.getParameterName(),"$litem2.getErrorMessage()"); } #end #end ##邮箱验证结束 ##对于颜色选择及日期选择而言,也是只需要各自验证自己的格式。 #elseif($litem1.getDisplayType().equals($displaytype.inputDateTimePicker)||$litem1.getDisplayType().equals($displaytype.inputColorPicker)) var str_$litem1.getParameterName()=jQuery.trim(jQuery("\#txt_$litem1.getParameterName()").text()); var tips_$litem1.getParameterName()=jQuery("\#tips_$litem1.getParameterName()"); SetSuccessTips(tips_$litem1.getParameterName(),""); #if($litem1.getDisplayType().equals($displaytype.inputColorPicker)) if(myv.isColor(str_$litem1.getParameterName())==false){ SetErrorTips(tips_$litem1.getParameterName(),"$litem1.getName_ZH()格式错误!"); isAllow=false; } #else if(myv.isDateTime(str_$litem1.getParameterName())==false){ SetErrorTips(tips_$litem1.getParameterName(),"$litem1.getName_ZH()格式错误!"); isAllow=false; } #end #*遍历规则*# #foreach($litem2 in $litem1.validatelist) #if($litem2.validateRuleType.equals($ruletype.getRule_isRequired())) if(myv.isRequired(str_$litem1.getParameterName())==false){ isAllow=false; SetErrorTips(tips_$litem1.getParameterName(),"$litem2.getErrorMessage()"); } #end #end ##颜色选择日期选择验证结束 ##最麻烦的是inputtext,需要验证多种东西 #else var str_$litem1.getParameterName()=jQuery.trim(jQuery("\#txt_$litem1.getParameterName()").text()); var tips_$litem1.getParameterName()=jQuery("\#tips_$litem1.getParameterName()"); SetSuccessTips(tips_$litem1.getParameterName(),""); #*遍历规则*# #foreach($litem2 in $litem1.validatelist) #if($litem2.validateRuleType.equals($ruletype.getRule_CustomRegex())) if(myv.CustomRegex(str_$litem1.getParameterName(),"$litem2.get("regex")")==false){ isAllow=false; SetErrorTips(tips_$litem1.getParameterName(),"$litem2.getErrorMessage()"); } #elseif($litem2.validateRuleType.equals($ruletype.getRule_NumberRange())||$litem2.validateRuleType.equals($ruletype.getRule_StringRange())) #if($litem2.validateRuleType.equals($ruletype.rule_NumberRange)) if(myv.NumberRange(str_$litem1.getParameterName(),"$litem2.get("min")","$litem2.get("max")")==false){ isAllow=false; SetErrorTips(tips_$litem1.getParameterName(),"$litem2.getErrorMessage()"); } #else if(myv.StringRange(str_$litem1.getParameterName(),"$litem2.get("minLen")","$litem2.get("maxLen")")==false){ isAllow=false; SetErrorTips(tips_$litem1.getParameterName(),"$litem2.getErrorMessage()"); } #end #else #set($vfunction=$litem2.getValidateRuleType().replaceFirst("rule_","")) if(myv.${vfunction}(str_$litem1.getParameterName())==false){ isAllow=false; SetErrorTips(tips_$litem1.getParameterName(),"$litem2.getErrorMessage()"); } #end #end ##inputtext验证结束 #end #end //其他验证规则请自行扩展。 return isAllow; } jQuery("\#btnSubmit_$formInfo.getFormID()").click(function () { var allow = checkparas(); if (allow == false) { art.dialog({ title: "内容填写有误", content: "内容格式有误,详情请查看错误提示。", ok: function () { }, okValue: "明白了" }); return; } art_ajax_json_dialog("#$formInfo.getFormID()", "post", "ajax_${formInfo.getEnglishName()}.jsp", function (data) { if (data.status == false) { art.dialog({ title: "操作失败", content: "" + data.message, okValue: "确定", ok: function () { } }); } else { art.dialog({ title: "成功保存记录", content: "" + data.message, okValue: "继续编辑", ok: function () { }, button: [ { value: "返回列表首页", callback: function () { // location.href = "list.jsp"; }, focus: true } ] }); } }); }); </script> </body> </html>
#* @vtlvariable name="javatype" type="CodeGen.customModel.util.JavaDataType" *### #* @vtlvariable name="displaytype" type="CodeGen.customModel.util.DisplayType" *### #* @vtlvariable name="formInfo" type="CodeGen.customModel.util.FormInfo" *### #* @vtlvariable name="StrWrapper" type="Easis.Common.StringUtilWrapper" *### #* @vtlvariable name="ruletype" type="CodeGen.customModel.util.ValidateRuleType" *### package EWeb.eForm; /** *作者:天桥下的码农 *生成的自定义表单为:$formInfo.getEnglishName()【中文:$formInfo.getChineseName()】 */ import java.util.Date; public class $formInfo.getEnglishName() { #foreach($litem1 in $formInfo.parameterList) public $StrWrapper.FirstLetterUpperCase($litem1.getParameterType()) $litem1.getParameterName(); #end }
#* @vtlvariable name="javatype" type="CodeGen.customModel.util.JavaDataType" *### #* @vtlvariable name="displaytype" type="CodeGen.customModel.util.DisplayType" *### #* @vtlvariable name="formInfo" type="CodeGen.customModel.util.FormInfo" *### #* @vtlvariable name="StrWrapper" type="Easis.Common.StringUtilWrapper" *### #* @vtlvariable name="ruletype" type="CodeGen.customModel.util.ValidateRuleType" *### package EWeb.Validator; import Easis.HTTP.RequestEnhance; import java.util.Hashtable; import Easis.Common.*; import java.text.SimpleDateFormat; import java.util.Date; import EWeb.eForm.$formInfo.getEnglishName(); public class ValidatorFor$StrWrapper.FirstLetterUpperCase($formInfo.getEnglishName()){ private RequestEnhance _re; public ValidatorFor${StrWrapper.FirstLetterUpperCase($formInfo.getEnglishName())}(RequestEnhance ReqEnhance){ this._re=ReqEnhance; } private ${formInfo.getEnglishName()} form_model=new ${formInfo.getEnglishName()}(); public Hashtable<String,Object> ErrorInfo(String message){ Hashtable<String,Object> hsres=new Hashtable<String,Object>(); hsres.put("status",false); hsres.put("message",""+message); return hsres; } public Hashtable<String,Object> SuccessInfo(String message){ Hashtable<String,Object> hsres=new Hashtable<String,Object>(); hsres.put("status",true); hsres.put("message",""+message); return hsres; } public Hashtable<String,Object> Validate(){ form_model=new ${formInfo.getEnglishName()}(); /*定义相关参数*/ #foreach($litem1 in $formInfo.parameterList) String origin_$litem1.getParameterName()=_re.fetchParamByPost("$formInfo.getPrefix()$litem1.getParameterName()"); if(origin_$litem1.getParameterName()==null){ return ErrorInfo("表单中并不包含【$litem1.getName_ZH()】的数据,请确认是否同一表单?"); } #end /*字符串验证*/ #foreach($litem1 in $formInfo.parameterList) #*判断布尔值,这个只能判断是不是布尔值类型了*# #if($litem1.getDisplayType().equals($displaytype.checkbox_Boolean)||$litem1.getDisplayType().equals($displaytype.radio_Boolean)) if(Validation.isBoolean(origin_$litem1.getParameterName())==false){ return ErrorInfo("【$litem1.getName_ZH()】并非布尔值"); } ##对于上传图片及上传文件来及URL,只需要验证是否必须及是否为url #elseif($litem1.getDisplayType().equals($displaytype.inputFileURL)||$litem1.getDisplayType().equals($displaytype.inputImgURL)) if(Validation.isURL(origin_$litem1.getParameterName())==false){ return ErrorInfo("【$litem1.getName_ZH()】URL格式错误。"); } #*遍历规则*# #foreach($litem2 in $litem1.validatelist) #if($litem2.validateRuleType.equals($ruletype.getRule_isRequired())) if(Validation.isRequired(origin_$litem1.getParameterName())==false){ return ErrorInfo("$litem2.getErrorMessage()"); } #end #end ##图片上传文件上传验证结束 ##对于邮箱而言只需要验证邮箱格式 #elseif($litem1.getDisplayType().equals($displaytype.inputEmailText)) if(Validation.isEmailAddr(origin_$litem1.getParameterName())==false){ return ErrorInfo("【$litem1.getName_ZH()】邮箱格式错误。"); } #*遍历规则*# #foreach($litem2 in $litem1.validatelist) #if($litem2.validateRuleType.equals($ruletype.getRule_isRequired())) if(Validation.isRequired(origin_$litem1.getParameterName())==false){ return ErrorInfo("$litem2.getErrorMessage()"); } #end #end ##邮箱验证结束 ##对于颜色选择及日期选择而言,也是只需要各自验证自己的格式。 #elseif($litem1.getDisplayType().equals($displaytype.inputDateTimePicker)||$litem1.getDisplayType().equals($displaytype.inputColorPicker)) #if($litem1.getDisplayType().equals($displaytype.inputColorPicker)) if(Validation.isColor(origin_$litem1.getParameterName())==false){ return ErrorInfo("【$litem1.getName_ZH()】只能包含数字和字母!"); } #else if(Validation.isDateTime(origin_$litem1.getParameterName())==false){ return ErrorInfo("【$litem1.getName_ZH()】日期格式错误(正确范例:2014-02-02)。"); } #end #*遍历规则*# #foreach($litem2 in $litem1.validatelist) #if($litem2.validateRuleType.equals($ruletype.getRule_isRequired())) if(Validation.isRequired(origin_$litem1.getParameterName())==false){ return ErrorInfo("$litem2.getErrorMessage()"); } #end #end ##颜色选择日期选择验证结束 ##最麻烦的是inputtex及hiddenfieldt,需要验证多种东西 #else #*遍历规则*# #foreach($litem2 in $litem1.validatelist) #if($litem2.validateRuleType.equals($ruletype.getRule_CustomRegex())) if(Validation.CustomRegex(origin_$litem1.getParameterName(),"$litem2.get("regex")")==false){ return ErrorInfo("$litem2.getErrorMessage()"); } #elseif($litem2.validateRuleType.equals($ruletype.getRule_NumberRange())||$litem2.validateRuleType.equals($ruletype.getRule_StringRange())) #if($litem2.validateRuleType.equals($ruletype.rule_NumberRange)) if(Validation.NumberRange(origin_$litem1.getParameterName(),"$litem2.get("min")","$litem2.get("max")")==false){ return ErrorInfo("$litem2.getErrorMessage()"); } #else if(Validation.StringRange(origin_$litem1.getParameterName(),"$litem2.get("minLen")","$litem2.get("maxLen")")==false){ return ErrorInfo("$litem2.getErrorMessage()"); } #end #else #set($vfunction=$litem2.getValidateRuleType().replaceFirst("rule_","")) if(Validation.${vfunction}(origin_$litem1.getParameterName())==false){ return ErrorInfo("$litem2.getErrorMessage()"); } #end #end ##inputtext验证结束 #end #end /*赋值*/ #foreach($litem1 in $formInfo.parameterList) #if($litem1.getParameterType().equals($javatype.getType_String())) form_model.$litem1.getParameterName()=origin_$litem1.getParameterName(); #elseif($litem1.getParameterType().equals($javatype.getType_Integer())) try{form_model.$litem1.getParameterName()= Integer.parseInt(origin_$litem1.getParameterName());} catch(Exception ef){ return ErrorInfo(ef.toString());} #elseif($litem1.getParameterType().equals($javatype.getType_Double())||$litem1.getParameterType().equals($javatype.getType_Float())||$litem1.getParameterType().equals($javatype.getType_Long())) try{form_model.$litem1.getParameterName()= ${StrWrapper.FirstLetterUpperCase($litem1.getParameterType())}.parse${StrWrapper.FirstLetterUpperCase($litem1.getParameterType())}(origin_$litem1.getParameterName());} catch(Exception ef){return ErrorInfo(ef.toString());} #elseif($litem1.getParameterType().equals($javatype.getType_Boolean())) form_model.$litem1.getParameterName()=StringUtil.Str2Boolean(origin_$litem1.getParameterName()); #elseif($litem1.getParameterType().equals($javatype.getType_Date())) try{ SimpleDateFormat sdf_temp = new SimpleDateFormat("yyyy-MM-dd"); form_model.$litem1.getParameterName()= sdf_temp.parse(origin_$litem1.getParameterName());} catch(Exception ef){return ErrorInfo(ef.toString());} #else /*$litem1.getParameterName()无*/ #end #end return SuccessInfo("所有参数都符合要求"); } public $formInfo.getEnglishName() getResult(){ return form_model; } }
#* @vtlvariable name="javatype" type="CodeGen.customModel.util.JavaDataType" *### #* @vtlvariable name="displaytype" type="CodeGen.customModel.util.DisplayType" *### #* @vtlvariable name="formInfo" type="CodeGen.customModel.util.FormInfo" *### #* @vtlvariable name="StrWrapper" type="Easis.Common.StringUtilWrapper" *### #* @vtlvariable name="ruletype" type="CodeGen.customModel.util.ValidateRuleType" *### <%@ page import="Easis.HTTP.RequestEnhance" %> <%@ page import="java.util.Hashtable" %> <%@ page import="Easis.Common.*" %> <%@ page import="EWeb.eForm.$formInfo.getEnglishName()" %> <%@ page import="EWeb.Validator.ValidatorFor$StrWrapper.FirstLetterUpperCase($formInfo.getEnglishName())" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <% RequestEnhance _re=new RequestEnhance(request); ValidatorFor$StrWrapper.FirstLetterUpperCase($formInfo.getEnglishName()) theValidator=new ValidatorFor${StrWrapper.FirstLetterUpperCase($formInfo.getEnglishName())}(_re); Hashtable<String,Object> hsres=theValidator.Validate(); boolean valid_res=StringUtil.Str2Boolean(hsres.get("status").toString()); if(valid_res==false){ out.print(JsonHelper.getJsonString(hsres));return; } $formInfo.getEnglishName() myform=theValidator.getResult(); out.print(JsonHelper.getJsonString(hsres));return; %>