user962206
user962206

Reputation: 16117

Struts2 xml-validation calling a method

Is it possible for an xxx-validation.xml to call a method? since my plan is that I would check a certain a value that it have received from the form and pass it as a parameter in a method (checks if the username exist in the db)

or ActionSupport class will invoke the validation.xml and then do a certain method

Upvotes: 1

Views: 1123

Answers (1)

Andrea Ligios
Andrea Ligios

Reputation: 50203

As i answered in a question from two days ago (!!), it is:

<validators>
    <field name="username">
        <field-validator type="fieldexpression">
            <param name="expression">
                <![CDATA[
                    isUserAlreadyInDatabase(username)
                ]]>
            </param>
            <message>function call message here</message>
        </field-validator>
    </field>
</validators>

Please consider to vote :)

Upvotes: 2

Related Questions