Struts 2
  1. Struts 2
  2. WW-2563

Improve Validation - Add Support for Bean Validation API (JSR 303) / Hibernate Validator

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Component/s: None
    • Labels:
      None

      Description

      Today the initial draft of the Bean Validation framework has been released. It would be nice if Struts' Validator would support JSR 303 and/or Hibernate validator.

      See also:

        Activity

        Hide
        Rene Gielen added a comment -

        I think I understand what Alfredo has in mind - have a generic validation plugin that embeds the JSR303 validation for whatever implementation was chosen. Most applications would have already chosen for a validation manager, say Hibernate validation, and don't need / want a second one, say OVal.

        I think the idea is valuable and it would be nice to see this implemented. Nevertheless, someone has to volunteer for this.

        That said - Alfredo, we always happily accept contributions!

        Show
        Rene Gielen added a comment - I think I understand what Alfredo has in mind - have a generic validation plugin that embeds the JSR303 validation for whatever implementation was chosen. Most applications would have already chosen for a validation manager, say Hibernate validation, and don't need / want a second one, say OVal. I think the idea is valuable and it would be nice to see this implemented. Nevertheless, someone has to volunteer for this. That said - Alfredo, we always happily accept contributions!
        Hide
        Dave Newton added a comment -

        Any plugin would require the inclusion of an existing implementation, unless S2 implements it itself, which is wasted effort. OVal includes a mechanism for making it JSR-303 compliant, so it is one of the existing implementations.

        Basically we're saying that JSR-303 compliance should come via plugins, regardless of the underlying implementation. We need hooks into the validation mechanism that can be used by implementation plugins.

        Show
        Dave Newton added a comment - Any plugin would require the inclusion of an existing implementation, unless S2 implements it itself, which is wasted effort. OVal includes a mechanism for making it JSR-303 compliant, so it is one of the existing implementations. Basically we're saying that JSR-303 compliance should come via plugins, regardless of the underlying implementation. We need hooks into the validation mechanism that can be used by implementation plugins.
        Hide
        Alfredo Osorio added a comment -

        The problem with that plugin is that it requires that you have OVal project. What we really need is something that integrates with the existing implementations of JSR-303.

        Show
        Alfredo Osorio added a comment - The problem with that plugin is that it requires that you have OVal project. What we really need is something that integrates with the existing implementations of JSR-303.
        Hide
        Lukasz Lenart added a comment -

        It's official Struts 2 plugin, so it isn't an alternative. IMHO we should not add support of JSR 303 directly to the Struts 2 Core - we have plugins for that.

        Show
        Lukasz Lenart added a comment - It's official Struts 2 plugin, so it isn't an alternative. IMHO we should not add support of JSR 303 directly to the Struts 2 Core - we have plugins for that.
        Hide
        Alfredo Osorio added a comment -

        That's an alternative but Struts should have it.

        Show
        Alfredo Osorio added a comment - That's an alternative but Struts should have it.
        Hide
        Lukasz Lenart added a comment - - edited

        Did you try to use OVal plugin ? OVal project already supports JSR 303

        Show
        Lukasz Lenart added a comment - - edited Did you try to use OVal plugin ? OVal project already supports JSR 303
        Hide
        Alfredo Osorio added a comment - - edited
        Show
        Alfredo Osorio added a comment - - edited I think this feature is very important. Spring MVC already implements it. http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html#validation-beanvalidation-overview
        Hide
        Brad Cupit added a comment -

        The problem with using the Hibernate Validator is that it expects the validation annotations to be on either a getter or a field.

        The xwork validator allows annotations on either the getters or the setters. Putting validation annotations on setters seems very natural to me, and the preferred way to go for Struts 2 Actions.

        The ideal situation (in my opinion) would be for setters to have the validation annotations, and for getters to be optional. I'm not sure if JSR 303 will address this.

        Show
        Brad Cupit added a comment - The problem with using the Hibernate Validator is that it expects the validation annotations to be on either a getter or a field. The xwork validator allows annotations on either the getters or the setters. Putting validation annotations on setters seems very natural to me, and the preferred way to go for Struts 2 Actions. The ideal situation (in my opinion) would be for setters to have the validation annotations, and for getters to be optional. I'm not sure if JSR 303 will address this.
        Hide
        Don Brown added a comment -

        We plan to address scoping in the 2.2 release

        Show
        Don Brown added a comment - We plan to address scoping in the 2.2 release

          People

          • Assignee:
            Unassigned
            Reporter:
            Gunnar Hillert
          • Votes:
            8 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

            • Created:
              Updated:

              Development