/bpmx_datayes/web/web-inf/view/platform/system/sysuseredit.jsp
An empty authentication mechanism
Interceptor Get JS
-----------------
<script type= "Text/javascript" src= "${ctx}/servlet/validjs?form=sysuser" ></script>
-----------------
Xml:
<servlet>
<servlet-name>ValidJS</servlet-name>
<servlet-class>com.hotent.core.web.servlet.ValidJs</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ValidJS</servlet-name>
<url-pattern>/servlet/ValidJs</url-pattern>
</servlet-mapping>
-------------------
Servlet--validjs
/**
* Obtain the JS code of customer segment certification according to the form name.
*/
protected void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {
Response.setcontenttype ("Text/javascript;charset=utf-8");
String form=requestutil.getstring (Request, "form");
Locale local= requestutil.getlocal (Request);
String str= "";
if (Stringutil.isnotempty (form))
{
try {
Str=validationutil.getjs (form, local);
} catch (Templateexception e) {
Str= "";
}
}
Response.getwriter (). print (str);
}
---------------------
/**
* Call the template engine to generate the validated JS.
* @param roleform
* @param Local
* @return
* @throws IOException
* @throws templateexception
*/
public static string Getjs (String Roleform,locale local) throws IOException, Templateexception
{
Freemarkengine freemaker= (freemarkengine) Apputil.getbean (Freemarkengine.class);
Gets the validation form object.
ValidForm form= getform (roleform, local);
Map map=new HashMap ();
Map.put ("form", form);
String str=freemaker.mergetemplateintostring ("VALIDJS.FTL", map);
return str;
}
--------------------------
GetForm Method:
Validatorfactory factory = (validatorfactory) beanfactoryutils.beanoftypeincludingancestors (CTX, Validatorfactory.class, True, true);
Validatorresources resources= factory.getvalidatorresources ();
Form frm= resources.getform (LOCAL:ZH_CN, Formname:sysuser);
----------------------------
Configuration file:
/bpmx_datayes/resources/resource/form_zh_cn.properties
Modified add: Sysuser.usercode=\u5458\u5de5\u7f16\u53f7
/bpmx_datayes/resources/conf/valid/formvalid.xml
Modify Add:
<field property= "Usercode" depends= "Required,maxlength" >
<arg position= "0" key= "Sysuser.usercode"/>
<arg position= "1" name= "maxlength" key= "${var:maxlength}"
Resource= "false"/>
<var>
<var-name>maxlength</var-name>
<var-value>20</var-value>
</var>
</field>
------------------
Related content in Form_zh_cn.properties
sysuser.fullname=\u59d3\u540d
Sysuser.account=\u5e10\u53f7
sysuser.password=\u5bc6\u7801
sysuser.isexpired=\u662f\u5426\u8fc7\u671f
sysuser.islock=\u662f\u5426\u9501\u5b9a
Sysuser.createtime=\u521b\u5efa\u65f6\u95f4
sysuser.status=\u72b6\u6001
Sysuser.email=\u90ae\u7bb1
sysuser.mobile=\u624b\u673a
Sysuser.phone=\u7535\u8bdd
Analytical:
Sysuser.fullname= Name
sysuser.account= Account
sysuser.password= Password
Whether the sysuser.isexpired= expires
Sysuser.islock= is locked
Sysuser.createtime= creation Time
sysuser.status= status
Sysuser.email= Mailbox
Sysuser.mobile= Mobile
Sysuser.phone= Telephone
--------------------------
Form Validate related content
<!--Start_sys_user--
<form name= "Sysuser" >
<field property= "FullName" depends= "MaxLength" >
<arg position= "0" key= "sysuser.fullname"/>
<arg position= "1" name= "maxlength" key= "${var:maxlength}"
Resource= "false"/>
<var>
<var-name>maxlength</var-name>
<var-value>127</var-value>
</var>
</field>
<field property= "Account" depends= "Required,maxlength" >
<arg position= "0" key= "Sysuser.account"/>
<arg position= "1" name= "maxlength" key= "${var:maxlength}"
Resource= "false"/>
<var>
<var-name>maxlength</var-name>
<var-value>20</var-value>
</var>
</field>
<field property= "Password" depends= "Required,maxlength" >
<arg position= "0" key= "Sysuser.password"/>
<arg position= "1" name= "maxlength" key= "${var:maxlength}"
Resource= "false"/>
<var>
<var-name>maxlength</var-name>
<var-value>50</var-value>
</var>
</field>
<field property= "isexpired" depends= "digits" >
<arg position= "0" key= "sysuser.isexpired"/>
</field>
<field property= "Islock" depends= "digits" >
<arg position= "0" key= "Sysuser.islock"/>
</field>
<field property= "status" depends= "number" >
<arg position= "0" key= "sysuser.status"/>
</field>
<field property= "Email" depends= "Email,maxlength" >
<arg position= "0" key= "Sysuser.email"/>
<arg position= "1" name= "maxlength" key= "${var:maxlength}"
Resource= "false"/>
<var>
<var-name>maxlength</var-name>
<var-value>128</var-value>
</var>
</field>
<field property= "mobile" depends= "Mobile,maxlength" >
<arg position= "0" key= "sysuser.mobile"/>
<arg position= "1" name= "maxlength" key= "${var:maxlength}"
Resource= "false"/>
<var>
<var-name>maxlength</var-name>
<var-value>32</var-value>
</var>
</field>
<field property= "Phone" depends= "Phone,maxlength" >
<arg position= "0" key= "Sysuser.phone"/>
<arg position= "1" name= "maxlength" key= "${var:maxlength}"
Resource= "false"/>
<var>
<var-name>maxlength</var-name>
<var-value>32</var-value>
</var>
</field>
</form>
<!--End_sys_user--
----------------------------
frm form
Form:sysuser
Field:
Key = FullName
property = FullName
Indexedproperty = null
Indexedlistproperty = null
Depends = MaxLength
page = 0
Fieldorder = 0
Vars:
Maxlength=var:name=maxlength value=127 Resource=false Jstype=null
Field:
Key = Account
property = Account
Indexedproperty = null
Indexedlistproperty = null
Depends = Required,maxlength
page = 0
Fieldorder = 0
Vars:
Maxlength=var:name=maxlength value=20 Resource=false Jstype=null
Field:
Key = password
property = password
Indexedproperty = null
Indexedlistproperty = null
Depends = Required,maxlength
page = 0
Fieldorder = 0
Vars:
Maxlength=var:name=maxlength value=50 Resource=false Jstype=null
Field:
Key = IsExpired
property = IsExpired
Indexedproperty = null
Indexedlistproperty = null
depends = digits
page = 0
Fieldorder = 0
Vars:
Field:
Key = Islock
property = Islock
Indexedproperty = null
Indexedlistproperty = null
depends = digits
page = 0
Fieldorder = 0
Vars:
Field:
Key = Status
property = Status
Indexedproperty = null
Indexedlistproperty = null
Depends = number
page = 0
Fieldorder = 0
Vars:
Field:
Key = Email
property = Email
Indexedproperty = null
Indexedlistproperty = null
Depends = Email,maxlength
page = 0
Fieldorder = 0
Vars:
Maxlength=var:name=maxlength value=128 Resource=false Jstype=null
Field:
Key = Mobile
property = Mobile
Indexedproperty = null
Indexedlistproperty = null
Depends = Mobile,maxlength
page = 0
Fieldorder = 0
Vars:
Maxlength=var:name=maxlength value=32 Resource=false Jstype=null
Field:
Key = Phone
property = Phone
Indexedproperty = null
Indexedlistproperty = null
Depends = Phone,maxlength
page = 0
Fieldorder = 0
Vars:
Maxlength=var:name=maxlength value=32 Resource=false Jstype=null
--------------------------
Original Validation method
?
function Showrequest (FormData, Jqform, options) {
return true;
}
var __valid;
function Showresponse (responsetext, statustext) {
var self=this;
var obj=new com.hotent.form.ResultMessage (ResponseText);
if (obj.issuccess ()) {//successful
$.ligerdialog.confirm (Obj.getmessage () + ", whether to continue operation", "hint Message", function (RTN) {
if (!RTN) {
var returnurl=$ ("#returnUrl"). Val ();
if ($ ("#returnUrl"). Length>0 && returnurl!= "") {
Location.href=returnurl;
Return
}
var linkback=$ ("A.back");
if (linkback.length>0) {
var returnurl=linkback.attr ("href");
if (returnurl!= "") {
Location.href=returnurl;
Return
}
}
}
else{
if (self.isreset==1) {
__valid.resetform ();
}
}
});
}else{//failure
$.ligerdialog.error (Obj.getmessage (), "error");
}
}
function valid (Showrequest,showresponse,isreset) {
var options={};
if (showrequest)
Options.beforesubmit=showrequest;
if (showresponse)
Options.success=showresponse;
if (Isreset) {
Options.isreset=isreset;
}
__valid=$ ("#sysUserForm"). Validate ({
Rules: {
fullname:{
maxlength:127
},
account:{
Required:true,
Maxlength:20
},
password:{
Required:true,
Maxlength:50
},
isexpired:{
Digits:true
},
islock:{
Digits:true
},
status:{
Number:true
},
email:{
Email:true,
maxlength:128
},
mobile:{
Mobile:true,
Maxlength:32
},
phone:{
Phone:true,
Maxlength:32
}
},
Messages: {
fullname:{
MaxLength: "Name up to 127 characters."
},
account:{
Required: "Account must be filled in",
MaxLength: "Account up to 20 characters."
},
password:{
Required: "Password Required",
MaxLength: "Password up to 50 characters."
},
isexpired:{
Digits: "The integer must be filled out if it expires."
},
islock:{
Digits: "Whether the lock must be filled in integers."
},
status:{
Number: "Status must be filled in numbers"
},
email:{
Email: "Please enter a valid email address."
MaxLength: "Mailbox up to 128 characters."
},
mobile:{
Mobile: "Cell phone number format is wrong",
MaxLength: "Phone up to 32 characters."
},
phone:{
Phone: "Wrong phone number format",
MaxLength: "Phone up to 32 characters."
}
},
Submithandler:function (form) {
$ (form). Ajaxsubmit (options);
},
Success:function (label) {
Label.removeclass ("error");
}
});
}
Validation of interception mechanisms through resource files