Announcement Announcement Module
Collapse
No announcement yet.
Validating HTTP GET Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validating HTTP GET

    What is the best way to do this in a controller ? I have a SimpleFormController extended and working, but I'd like to redirect to an error page if some attributes are missing.


    Sf

  • #2
    Are these attributs mapped to the command? If so, redirect to an error page will be done automatically. If the attributes are not mapped to the command, one solution is to create an intercetor to do the validation and redirect to what ever error page you want.
    Hope this helps.

    Comment


    • #3
      An example ?

      Thank you,

      but can you please provide me with a simple example ?

      I have a

      this.setCommandClass(CheckInBean.class);

      in the constructor of the controller.

      This bean is POJO with nothing in it except private variables and getters/setters.

      So how do I do that validation of a GET request ?

      Thanks.

      Sf

      Comment


      • #4
        Is the GET request considered a form submission? If so, override isFormSubmission() and then validation will occur.

        If you want to validate on GET, but not treat it as a form submission, then there are two ways to do this.

        To simply check for missing parameters, the binding framework can do this with ease. You can configure the binder, inside initBinder(), to check for mandatory fields. Simply call binder.setRequiredFields(), passing in the names of the fields that must exist.

        You could also override onBindOnNewForm(), and do whatever custom processing there.

        I recommend using the binder to check for required fields, however.

        Comment

        Working...
        X