You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yanto <ya...@gmail.com> on 2009/06/16 09:44:41 UTC

validator issue in Struts 2.16

Hi,


I am trying to use the struts validation xml and testing with my action but
its not working in struts 2.1.6 .

Same code working fine in struts 2.0.6



Any issue in the 2.1.6 version ? Are we need to include any interceptor ?



I pasted below my codes.    Any one had same issue previously ?



Code same:



QuizAction-validation.xml:



<?xml version=*"1.0"* encoding=*"UTF-8"*?>

<!DOCTYPE validators PUBLIC

            "-//OpenSymphony Group//XWork Validator 1.0.2//EN"

            "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">



<validators>

    <field name=*"name"*>

        <field-validator type=*"requiredstring"*>

            <message>You must enter a name</message>

        </field-validator>

    </field>

    <field name=*"age"*>

        <field-validator type=*"int"*>

            <param name=*"min"*>13</param>

            <param name=*"max"*>19</param>

            <message>Only people ages 13 to 19 may take this quiz</message>

        </field-validator>

    </field>

</validators>





*package* test;



*import* com.opensymphony.xwork2.ActionSupport;



*public* *class* QuizAction *extends* ActionSupport {



    *private* *static* *final* *long* *serialVersionUID* =
-7505437345373234225L;



    String name;

    *int* age;

    String answer;



    *public* String getName() {

        *return* name;

    }



    *public* *void* setName(String name) {

        *this*.name = name;

    }



    *public* *int* getAge() {

        *return* age;

    }



    *public* *void* setAge(*int* age) {

        *this*.age = age;

    }



    *public* String getAnswer() {

        *return* answer;

    }



    *public* *void* setAnswer(String answer) {

        *this*.answer = answer;

    }

}



<package name=*"test"* namespace=*"/test"* extends=*"struts-default"*>



        <action name=*"test"* class=*"test.QuizAction"*>

                  <result name=*"success"*>/input.*jsp*</result>

                  <result name=*"error"*>/input.*jsp*</result>

                  <result name=*"input"*>/input.*jsp*</result>

                  </action>

    </package>





Thanks

Yanto