Threadinar13 - Double Range, Length & Long Range Validator Components

Hi All,

This is the thirteenth in theThreadinar series. See theComponents Threadinar Index at http://forum.sun.com/jive/thread.jspa?threadID=103424 for the complete list to date.

This Threadinar will discuss the 3 components in the "Components Palette: Validator Section" of the Creator Component Catalog.

The components we will focus on today are

"Double Range Validator", "Length Validator" & "Long Range Validator" Components.

Let us begin our discussion with the "Double Range Validator" Component.

What Is a Validator?

If your application collects information from users, for example a login and a password, then it is important that you verify the user data. The IDE provides a set of components for validating user input. These validators, which you access from the Validators section of the Components Palette, are as follows:

Double Range Validator Component

A Double Range validator is typically used to validate that the value of a component does not exceed the standard range of the Java double data type. This data type represents a double floating-point number that ranges from ?39E-324 to ?.7976931348623157E+308. Typically, the way you add a validator to a JavaServer Faces component is to edit the component's validator property, which provides a drop-down list from which you can select a validator.

Use a Double Range validator to test whether the user has entered a double data type value within the range defined by the specified minimum and maximum values. The value must be floating-point or convertible to floating-point.

Length Validator Component

A Length validator is used to validate that the length of text entered for a component is no shorter or longer than the values you specify for the validator's min and max properties. The validation occurs after the page is submitted. Typically, the way you add a validator to a JavaServer Faces component is to edit the component's validator property, which provides a drop-down list from which you can select a validator.

Use a Length validator to test whether user has entered a string of a length defined by the specified minimum and maximum values. The value must be a java.lang.String.

Long Range Validator Component

A Long Range validator is used to validate that the value of a component does not exceed the standard range of the Java long data type. This data type is a signed integer that ranges from -263 to 263-1, or

-9223372036854775808 to 9223372036854775807. Typically, the way you add a validator to a JavaServer Faces component is to edit the component's validator property, which provides a drop-down list from which you can select a validator.

Use a Long Range validator to test whether user has entered an integer of a size defined by the specified minimum and maximum values. The value must be any numeric type or String that can be converted to a long.

You can use more than one validator on an input component to validate for different criteria. When you use a validator, your component also needs a message component to indicate when the validation fails.

See Also

For more details on

"Using Validators", Please see the tutorial at

http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/val idators_converters.html

Customizing a Standard Validator Message

http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/cus tommessage.html

and

Adding Your Own Validation Handler

http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/cus tomvalidator.html

- --

Please share your comments, experiences, additional information, questions, feedback, etc. on these components.

- --

[3925 byte] By [kish@suna] at [2007-11-26 13:23:25]
# 1
.
kish@suna at 2007-7-7 17:55:50 > top of Java-index,Development Tools,Java Tools...