Announcement Announcement Module
Collapse
No announcement yet.
Check submit button in Validator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check submit button in Validator

    I have a form with three different submit buttons and I need to know which button is clicked when I do the validation of the submitted input. I would like to do all the validation in Validator.validate().
    How can this be done most easily? Is there any way to get access to the request object in the Validator class?

    All input will be highly appreciated!

  • #2
    Originally posted by aandas99
    I have a form with three different submit buttons and I need to know which button is clicked when I do the validation of the submitted input. I would like to do all the validation in Validator.validate().
    How can this be done most easily? Is there any way to get access to the request object in the Validator class?

    All input will be highly appreciated!
    You can't access the request object in an Validator implementation. If you want to access the request object you can override the onBindAndValidate() method (in a SimpleFormController for example) and use WebUtils.hasSubmitParameter() to see what submit button was used. Another way would be to add all the submit buttons to your command object - then you can test them in your Validator implementation.


    HTH
    Oliver

    Comment


    • #3
      If I bind all the submit buttons to the command object, how do I know what button is used?

      Comment


      • #4
        Originally posted by aandas99
        If I bind all the submit buttons to the command object, how do I know what button is used?
        Only the pressed submit button contains a (the in the html specified) value. The others are null.

        Comment


        • #5
          Thanks, I think I will go for that solution!

          Comment

          Working...
          X