alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  
* <td class='confluenceTd'> no * * <td class='confluenceTd'> Add list of RequiredFieldValidators * </tr> * <tr> * <td class='confluenceTd'> customValidators * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of CustomValidators * </tr> * <tr> * <td class='confluenceTd'> conversionErrorFields * * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of ConversionErrorFieldValidators * </tr> * <tr> * <td class='confluenceTd'> dateRangeFields * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of DateRangeFieldValidators * </tr> * <tr> * <td class='confluenceTd'> emails * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of EmailValidators * </tr> * <tr> * <td class='confluenceTd'> fieldExpressions * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of FieldExpressionValidators * </tr> * <tr> * <td class='confluenceTd'> intRangeFields * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of IntRangeFieldValidators * </tr> * <tr> * <td class='confluenceTd'> requiredStrings * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of RequiredStringValidators * </tr> * <tr> * <td class='confluenceTd'> stringLengthFields * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of StringLengthFieldValidators * </tr> * <tr> * <td class='confluenceTd'> urls * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of UrlValidators * </tr> * <tr> * <td class='confluenceTd'> visitorFields * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of VisitorFieldValidators * </tr> * <tr> * <td class='confluenceTd'> regexFields * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of RegexFieldValidator * </tr> * <tr> * <td class='confluenceTd'> expressions * <td class='confluenceTd'> no * <td class='confluenceTd'> Add list of ExpressionValidator * </tr> * </table> * <!-- END SNIPPET: parameters --> * * <p/> Example code: * * <pre> * <!-- START SNIPPET: example --> * @Validations( * requiredFields = * {@RequiredFieldValidator(type = ValidatorType.SIMPLE, fieldName = "customfield", message = "You must enter a value for field.")}, * requiredStrings = * {@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "stringisrequired", message = "You must enter a value for string.")}, * emails = * { @EmailValidator(type = ValidatorType.SIMPLE, fieldName = "emailaddress", message = "You must enter a value for email.")}, * urls = * { @UrlValidator(type = ValidatorType.SIMPLE, fieldName = "hreflocation", message = "You must enter a value for email.")}, * stringLengthFields = * {@StringLengthFieldValidator(type = ValidatorType.SIMPLE, trim = true, minLength="10" , maxLength = "12", fieldName = "needstringlength", message = "You must enter a stringlength.")}, * intRangeFields = * { @IntRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "intfield", min = "6", max = "10", message = "bar must be between ${min} and ${max}, current value is ${bar}.")}, * dateRangeFields = * {@DateRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "datefield", min = "-1", max = "99", message = "bar must be between ${min} and ${max}, current value is ${bar}.")}, * expressions = { * @ExpressionValidator(expression = "foo > 1", message = "Foo must be greater than Bar 1. Foo = ${foo}, Bar = ${bar}."), * @ExpressionValidator(expression = "foo > 2", message = "Foo must be greater than Bar 2. Foo = ${foo}, Bar = ${bar}."), * @ExpressionValidator(expression = "foo > 3", message = "Foo must be greater than Bar 3. Foo = ${foo}, Bar = ${bar}."), * @ExpressionValidator(expression = "foo > 4", message = "Foo must be greater than Bar 4. Foo = ${foo}, Bar = ${bar}."), * @ExpressionValidator(expression = "foo > 5", message = "Foo must be greater than Bar 5. Foo = ${foo}, Bar = ${bar}.") * } * ) * public String execute() throws Exception { * return SUCCESS; * } * <!-- END SNIPPET: example --> * </pre> * * @author jepjep * @author Rainer Hermanns * @version $Id: Validations.java 894090 2009-12-27 18:18:29Z martinc $ */ @Target( { ElementType.METHOD, ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) public @interface Validations { /** * Custom Validation rules. */ public CustomValidator[] customValidators() default {}; public ConversionErrorFieldValidator[] conversionErrorFields() default {}; public DateRangeFieldValidator[] dateRangeFields() default {}; public EmailValidator[] emails() default {}; public FieldExpressionValidator[] fieldExpressions() default {}; public IntRangeFieldValidator[] intRangeFields() default {}; public RequiredFieldValidator[] requiredFields() default {}; public RequiredStringValidator[] requiredStrings() default {}; public StringLengthFieldValidator[] stringLengthFields() default {}; public UrlValidator[] urls() default {}; public ConditionalVisitorFieldValidator[] conditionalVisitorFields() default {}; public VisitorFieldValidator[] visitorFields() default {}; public RegexFieldValidator[] regexFields() default {}; public ExpressionValidator[] expressions() default {}; }

Other Struts examples (source code examples)

Here is a short list of links related to this Struts Validations.java source code file:

Struts example source code file (Validations.java)

This example Struts source code file (Validations.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Struts tags/keywords

annotation, conditionalvisitorfieldvalidator, conversionerrorfieldvalidator, customvalidator, expressionvalidator, fieldexpressionvalidator, intrangefieldvalidator, regexfieldvalidator, requiredfieldvalidator, requiredstringvalidator, stringlengthfieldvalidator, target, urlvalidator, validations, visitorfieldvalidator

The Struts Validations.java source code

/*
 * Copyright 2002-2006,2009 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.opensymphony.xwork2.validator.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * <!-- START SNIPPET: description -->
 * <p>If you want to use several annotations of the same type, these annotations must be nested within the @Validations() annotation.

* <!-- END SNIPPET: description --> * * <p/> Annotation usage: * * <!-- START SNIPPET: usage --> * <p/>Used at METHOD level. * <!-- END SNIPPET: usage --> * * <p/> Annotation parameters: * * <!-- START SNIPPET: parameters --> * <table class='confluenceTable'> * * <tr> * <th class='confluenceTh'> Parameter * <th class='confluenceTh'> Required * <th class='confluenceTh'> Notes * </tr> * <tr> * <td class='confluenceTd'> requiredFields
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.