alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Struts example source code file (SimpleAction-validation.xml)

This example Struts source code file (SimpleAction-validation.xml) 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

bar, bar, could, could, doctype, doctype, foo, group//xwork, group//xwork, opensymphony, public, validator

The Struts SimpleAction-validation.xml source code

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd">
<validators>
    <field name="bar">
        <field-validator type="required">
            <message>You must enter a value for bar.
        </field-validator>
        <field-validator type="int">
            <param name="min">6
            <param name="max">10
            <message>bar must be between ${min} and ${max}, current value is ${bar}.
        </field-validator>
    </field>
    <field name="percentage">
        <field-validator type="double">
            <param name="minExclusive">0.1
            <param name="maxExclusive">10.1
            <message>percentage must be between ${minExclusive} and ${maxExclusive}, current value is ${percentage}.
        </field-validator>
    </field>
    <field name="date">
        <field-validator type="date">
            <param name="min">12/22/2002
            <param name="max">12/25/2002
            <message>The date must be between 12-22-2002 and 12-25-2002.
        </field-validator>
    </field>
    <field name="foo">
        <field-validator type="int">
            <param name="min">0
            <param name="max">100
            <message key="foo.range">Could not find foo.range!
        </field-validator>
    </field>
    <field name="baz">
        <field-validator type="int">
            <param name="min">0
            <message key="baz.range">Could not find baz.range!
        </field-validator>
    </field>
    <field name="longFoo">
        <field-validator type="long">
            <param name="min">0
            <param name="max">100
            <message key="foo.range">Could not find foo.range!
        </field-validator>
    </field>
    <field name="shortFoo">
        <field-validator type="short">
            <param name="min">0
            <param name="max">100
            <message key="foo.range">Could not find foo.range!
        </field-validator>
    </field>
    <validator type="expression">
        <param name="expression">foo > bar
        <message>Foo must be greater than Bar. Foo = ${foo}, Bar = ${bar}.
    </validator>
</validators>

Other Struts examples (source code examples)

Here is a short list of links related to this Struts SimpleAction-validation.xml source code file:

... 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.