简体   繁体   English

Tapestry服务器端的日期验证

[英]date validation in tapestry server side

Im trying to put some validation in the date field. 我试图在日期字段中进行一些验证。 The condition is the effective date field should be less or equal to the current date and it should be 1st of month. 条件是生效日期字段应小于或等于当前日期,并且应为每月1号。

Im doing it in tapestry.The data type is DATE. 我正在挂毯中做它。数据类型是DATE。 im using tapestry as yo know you will have .html page a, .java file and .page file. 我正在使用挂毯,因为我知道您将拥有.html页面a,.java文件和.page文件。 Im doing it in the java file . 我在java文件中执行此操作。 So please help me on this. 所以请帮我。

When the form is submitted t5 emits various events during the different stages. 提交表单后,t5在不同阶段会发出各种事件。 On EventConstants.VALIDATE is a good place to perform more complex validations that are not supported by t5 out of the box, or to perform cross-field validation serverside. 在EventConstants.VALIDATE上是开箱即用的t5不能执行的更复杂的验证或在服务器端执行跨字段验证的好地方。

    @Component
    private Form myForm;
    ...
    @OnEvent(value = EventConstants.VALIDATE, component = "myForm")
    public void onCreateEditValidate() {
       // do validation and if any error record it
       myForm.record(theDateField, "Dang, try again!");
       ...

http://tapestry.apache.org/forms-and-validation.html http://tapestry.apache.org/forms-and-validation.html

You can use the onValidate event too as stated at the end of the link jon martin solas posted. 您也可以使用jon martin solas发布的链接结尾处所述的onValidate事件。 Something like: 就像是:

void onValidateFromYouDateFieldId(..) throws ValidationException{
   //your custom validations
}

you can check out this example for more information: 您可以查看此示例以获取更多信息:

http://jumpstart.doublenegative.com.au/jumpstart/examples/input/morevalidation http://jumpstart.doublenegative.com.au/jumpstart/examples/input/morevalidation

http://tapestry.apache.org/forms-and-validation.html#FormsandValidation-OverridingtheTranslatorwithEvents http://tapestry.apache.org/forms-and-validation.html#FormsandValidation-OverrideingTranslatorwithEvents

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM