struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mailtolouis2020-str...@yahoo.com
Subject Re: Struts 2 - Global Validation
Date Thu, 04 Feb 2010 15:45:40 GMT
Hi,

I've similar problem with you and posted the similar question just not long ago, but still
not found any solution yet.

Look like struts2 not supporting this feature anymore :(

Pls let me know if you find any solution. Thanks.

LV




________________________________
From: Arulmani V A <arulmani_s@yahoo.com>
To: Struts Users Mailing List <user@struts.apache.org>
Sent: Wed, February 3, 2010 8:27:27 PM
Subject: Struts 2 - Global Validation

Hi, 

Any idea how to do global validation in Struts 2 ?

For example, in Struts 1, I can define all global regular expression validations in a file
called validation-regexpr.xml such as :


<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE form-validation PUBLIC
        "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
        "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

<form-validation>
    <global>
        <constant>
            <constant-name>alpha</constant-name>
            <constant-value>[A-Za-z]*</constant-value>
        </constant>
    </global>
</form-validation>

The above global regular expressions can be reused in other validation files as follows :


<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE form-validation PUBLIC
        "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.2.0//EN"
        "http://jakarta.apache.org/commons/dtds/validator_1_2_0.dtd">

<form-validation>
    <formset>
        <form name="EmployeeForm">
            <field property="EmployeeName" depends="mask">
                <msg name="mask" key="errors.invalid" />
                <arg position="0" key="label.EmployeeName" />
                <var>
                    <var-name>mask</var-name>
                    <var-value>${alpha}</var-value>
                </var>
            </field>
        </form>
    </formset>
</form-validation>


I could not get information on how to do this in Struts 2, no luck with the Struts2 e-books
also. Any help in this regard will be greatly appreciated ....

Regards
Arul




      Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! http://downloads.yahoo.com/in/internetexplorer/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message