Same Old Question: Struts validator package vs POJO validation

Discussions

Web tier: servlets, JSP, Web frameworks: Same Old Question: Struts validator package vs POJO validation

  1. Hi All,

    I am sure this question has been answered before. I am juggling with few decisions relating validation in web applications.
    If I am to implement validation at the Form level, do I use struts validator or write my own validation that extends ActionForm class and have the xxxForm extend it as well:
    (class ValidationClass extends ActionForm{}
     class xxxForm extends ValidationClass{}
    )
     
    I think configuring an XML struts-validator will take longer than writing my own validator to do the same thing.
    the other decision is to move validation all together from the web tier to the business tier.

    Can some one please enlighten us?

    A
  2. Hi All,

    >
    > I am sure this question has been answered before. I am juggling with few decisions relating validation in web applications.
    > If I am to implement validation at the Form level, do I use struts validator or write my own validation that extends ActionForm class and have the xxxForm extend it as well:
    > (class ValidationClass extends ActionForm{}
    >  class xxxForm extends ValidationClass{}
    > )
    >  
    > I think configuring an XML struts-validator will take longer than writing my own validator to do the same thing.
    > the other decision is to move validation all together from the web tier to the business tier.
    >
    > Can some one please enlighten us?
    >
    > A
    Hi
    Basically there are two questions
    1. Whether to do the validation on web tier or business tier?
    2. If you use web tier,Whether to use Struts validator or use POJO validation using actionform's validate method?

    The answer to the first question is use validation at both tiers. This basically boils down to client side validation and server side validation. One of the recommendation is to validate early and validate everything. Based on this I would recommend using validation at both tiers.

    To answer second question (dependent on answer to first question assuming you want to use client side validation)
    I agree struts validator will take more time. However struts validator is more powerful as it supports javascript and also you could reuse the validation rules and all the validation rules are at a central place. As long as the struts validator can support all the validation requirement (client side) of your application , I would go with struts validator.

    Hope this helps
  3. I couldn't agree with you more.
    Thank you very much for the clarification.
  4. Don't agree[ Go to top ]

    Well I'm a firm believer of kicking JavaScript to a place where the sun doesn't shine. I prefer doing all my check using just POJO's and nowadays more and more regular expressions. But I'm still looking for a framework where I can see which field have been modified in the web form. I.e. We submit a form, do a lot of checks, there is an invalid field, user adjusts that field but leaves all the rest as it was. Then normally we should recheck every field.

    Anyone knows a good technique for solving this kind of problem?