Announcement Announcement Module
Collapse
No announcement yet.
Spring validation for non-Spring UI? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring validation for non-Spring UI?

    We are building a system where we use Spring on server side only. For UI we are using Flex. Now there are some requirements where although we have Front end input validation from Flex, we have to duplicate those on server side as well because purpose of this system is to make it independent from Front end and if client wants to thrown in their own different front end they can use only our backend Spring services.

    my question is what's the best way to implement client validations on server side using Spring? I see some built in classes but yet not sure how exactly will I pass response to caller(Front end)? For e.g. Field A can only accept numbers, how do I pass an validation error to front end? If not possible with Spring then what's the best way?

    Any inputs are welcome.

    Thanks,
    Last edited by javaxmlsoapdev; Nov 14th, 2006, 12:08 PM.

  • #2
    This may actually be a Flex question. If you're not using Spring MVC you won't want to use its validation mechanism--best to keep the server-side validation then in your business objects, returning exceptions to be trapped/reported by Flex as appropriate.

    Glen

    Comment


    • #3
      Originally posted by gmazza View Post
      This may actually be a Flex question. If you're not using Spring MVC you won't want to use its validation mechanism--best to keep the server-side validation then in your business objects, returning exceptions to be trapped/reported by Flex as appropriate.

      Glen
      you probably didn't get my question correctly. This is not a Flex question. Flex is only for UI. Our backend services, business logic everything is using Spring mechanism. I want to keep server side validations in business layer and want to pass them to UI layer. My question was how to pass them when UI is not SpringMVC.

      From this link http://static.springframework.org/sp...alidation.html I think I can use Spring validation regardless of what technology we use in UI layer? However I am not fully sure about how to pass "org.springframework.validation.Errors" to Flex layer? Since "org.springframework.validation.Errors" is an interface how do I pass it (non-serialized) interface to Front end? Passing interface to front end wouldn't help though? or something similiar? If not then what's the other best approach? Any ideas?

      Comment


      • #4
        Originally posted by javaxmlsoapdev View Post
        you probably didn't get my question correctly. This is not a Flex question. Flex is only for UI. Our backend services, business logic everything is using Spring mechanism. I want to keep server side validations in business layer and want to pass them to UI layer. My question was how to pass them when UI is not SpringMVC.
        I'm not sure--this really *does* appear to be a Flex question. You want to keep server side validations in business layer. OK. So your business layer is going to throw Java exceptions should domain values be invalid, correct? It appears that the next question is, how can I get Flex to trap and report on Java exceptions? That question is Flex-specific.

        I think I can use Spring validation regardless of what technology we use in UI layer?
        You can use the Spring MVC validation process for those UI outputs supported by SpringMVC, I'm not sure if Flex is supported by SpringMVC. But you'll need to be using SpringMVC to take advantage of it, because this is where this validation process is coded.

        However I am not fully sure about how to pass "org.springframework.validation.Errors" to Flex layer? Since "org.springframework.validation.Errors" is an interface how do I pass it (non-serialized) interface to Front end? Passing interface to front end wouldn't help though? or something similiar? If not then what's the other best approach? Any ideas?
        I don't know--I don't worry about this stuff because I use SpringMVC. But as far as I can tell, the answers to these questions are "any way you want". If you're not using SpringMVC, you'll need to create another framework to handle client-side reporting of errors generated from your business objects, so it depends on how you choose to code it. Perhaps looking at the SpringMVC source may be of help.

        Glen

        Comment


        • #5
          I suggest you to use valang validator for your beck end.
          See the spring-modules

          Comment


          • #6
            Valang is just a one-for-one XML replacement of a Validator-interface implementing Java class, it will not solve the underlying problem of the validation infrastructure that Javaxmlsoapdev needs. It is easy to install[1], and works beautifully for 60-70% of use cases, but has some annoying limitations[2]. As a matter of fact, [2] mentioned a new "Bean Validation Framework" in Spring Modules that I know nothing about--however it might be a good avenue for Javaxmlsoapdev to explore.

            [1] http://www.jroller.com/page/gmazza?e..._initial_setup

            [2]
            http://opensource.atlassian.com/proj...browse/MOD-152

            Comment


            • #7
              I agree with you about % of problem that valang not solve.
              Obviously is possible to use it as "base" for realize a validation for beck-end (create custom function at least or extends it for particular case).
              For me is better create few class using valang (for solve 30% of problems that it not solve) that create class for validate each BO; but is my opinion.
              Is possible to use the same configuration file for generate javascript or apply validation in beck-end; for me, actually,it is the best solution to use for this rule, extend it (adding the feature that you need) and use.

              Valang is no mature, but is easy extends it for adding more feature (taht particular domain need)
              If someone know a similar module for apply validation both client-side/beck-end tell me, i'm very interest on it

              Comment


              • #8
                I am leaning towards using Jakarta's commons validator framework, which is very matured rather than trying some framework, which is still in sandbox stage? Any inputs?

                Do you think commons validator would work 100% for all use case? Any watch points or word of caution or things to keep in mind while using this? Or this framework won't be a good choice??

                Comment


                • #9
                  Commons Validator is mature, Struts use it for validate the input forms from years..

                  You can use cv in standalone model so you can validate client and server-side, but, imho, is the rigth choise if you use Struts as MVC for some reason (people that develop with struts already know it => ++ maintenance,ecc), not your case

                  In any case you should adapt it on your domain => create custom validator and so on...
                  and the goal of cv is validate html form, for it is more difficult adapt it for validate your vo in beck-end (ex checking nested values or check value of objects in collection and so on)...for me is better (and easy ) use valang validator and add the feature that you need...

                  OC, i assume that you whould not execute the validation in programmatic way, for it i suggest you valang that use xml file for store the rules; if you can/would use programmatic way there are better solution
                  Last edited by amodena; Nov 17th, 2006, 04:51 AM.

                  Comment

                  Working...
                  X