Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SmartGWT, Spring and validation

    Hi, i'm looking into perhaps unifying smartGWT with calls we have for other interfaces. We use Spring everywhere, and Web controllers. As part of that, we use a lot of validation annotation (@Valid, max etc), but if the calls come in from the smartgwt IdaCall servlet, the @Valid annotation in the Spring bean method parameters are ignored. (i use lookupstyle=spring to have IdaCall use my Spring MVC beans).

    I looked at your spring integration docs, but it only talks about how to integrate Spring controllers in a rudimentary fashion, and integrate Spring transactions, but there's nothing on spring validation.

    Is there any way to make the request chain use Spring mvc annotated validation with SmartGWT?

    Edit, to elaborate a bit:
    In your docs, you say (in "using spring controllers..."):
    "This lets you use Spring's DispatchServlet, Handler chain and Controller architecture"

    But as far as i can see, methods annotated with for example
    Code:
     
     public @ResponseBody List<ScheduleItem> add(@RequestBody @Valid ScheduleItemTO item, HttpServletResponse resp)
    , the @valid is ignored and the spring validation that usually occurs, does not if the call comes in from IDACall.
    Last edited by mathias; 8 Jun 2020, 00:41.

    #2
    Spring validation cannot extend to the client-side, as SmartGWT can, with a single definition. We would instead recommend just having callers use the built-in RestHandler servlet, which in 13.0 now supports OpenAPI, so you have a fully documented API that explains validation rules to clients, and supports necessary use cases like advanced criteria and transactions. You get all of that by just declaring a DataSource.

    If you are already stuck with a lot of Spring validation definitions, you could instead use a DynamicDSGenerator to build SmartClient DataSource definitions, complete with validators, by dynamically inspecting your Spring declarations. Then you would get client-side validation and OpenAPI support "for free". But, after all that work, you'd have a far less capable system, which would also be less dynamic (eg, unable to support use cases like Reify.com). So, not an appealing product direction, since it would be a huge backwards step relative to what we already have, but if you are already stuck with a lot of Spring validation definitions, perhaps the best path forward for you.

    Comment


      #3
      Right. What i was asking was if there was any way to make the IDACall use javax.validation rules defined in existing spring/transferobject code. It's not an option to migrate our current web controllers into RestHandler right now. Going the DynamicDSGenerator route would only "copy" the Spring validators, not actually execute them.

      Thanks for responding though, i guess we'll figure something else out.

      Comment


        #4
        The idea would be to translate the Spring validation definitions to SmartGWT validators, via DynamicDSGenerator. Then, of course they execute. This gets you client-side validation, and gets you server-side validation as well, from a single source.

        Comment


          #5
          Sure. I'll take a look. Thanks.

          Comment

          Working...
          X