1

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

Roman C
  • 49,761
  • 33
  • 66
  • 176
user962206
  • 15,637
  • 61
  • 177
  • 270

1 Answers1

2

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 :)

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • Oops, I didn't saw your answer from my previous question. Sorry low latency internet connection here. but wait, where would I register or create that method? is there a class I should use? – user962206 Dec 20 '12 at 09:41
  • your Action (or an Action extended by your Action, let's say BaseAction, if the method to call is common...) – Andrea Ligios Dec 20 '12 at 09:42
  • is this considered as bad practice? – user962206 Dec 20 '12 at 09:45
  • I used this to check data from session, I've never did it to query a database, i wrote that would be a bad practice but I may be wrong... i'll edit to put some doubt on it :) – Andrea Ligios Dec 20 '12 at 09:51