|
From: John C. <joh...@sa...> - 2003-03-05 21:53:25
|
Juergen, Please see inline. >=20 > Spring's validator framework is definitely meant to be reusable = across > presentation and business logic layers. This is a major USP compared = to > Struts' web-centric validation support. [John Cavacas]=20 Agreed. Which is why I am exploring its use. >=20 > You can define validator beans in your application context, e.g. a > "userValidator" bean that implements = com.interface21.validation.Validator > and supports your User class. The bean definition can configure the > validator via its properties. You can assign this bean to respective > CommandController/FormController implementations as "validator" bean > reference easily, for web controller validation. This is shown in = chapter > 12 of Rod's book. >=20 [John Cavacas]=20 This is exactly what I have done. However I haven't defined it in a CommandController/FormController as of yet. As it stands now, the only = usage of the validator is in my unit tests, but like you said I will be able = to just make it available to my controller and use it. > Beyond usage in web controllers, you can assign your validator bean = to any > business logic services too, easily via bean reference if your = services > are registered as beans in your application context. For services = outside > of the application context, you could assign the validator bean = manually > by getting a reference to the application context, looking up the = bean, > and setting it to your service instance. All of this would work in a > standalone application too, if it utilizes a Spring application = Context. >=20 [John Cavacas]=20 Now this is the problem that I am dealing with currently (well I = haven't had time to look at it in the past couple of days). My business object is a = bean and it is configured by the framework. Let me explain a bit more about = my current design. My business object is simply a JavaBean that uses a DAO object (which in turn makes use of the JDBC and bean Framework). You = are right in saying that I can make the validator object also available to = the Business Object, however the Business Object is the one responsible for using the DAO to find out for example, if an email address is already = in the database. How do you suggest that the validator have access to that = kind of functionality/data? Should it have a reference to the DAO as well? = Should it call back the Business Object? That's the issue that I am dealing with = as it seems that the separation of concerns becomes mixed up if I do that.=20 Could you perhaps explain how you would solve this problem in more = detail? Or rather how the framework Validator can be reused across multiple = layers. Maybe I'm just not seeing it. > Therefore, I don't see a need for validator plug-ins or the like. = This > demonstrates the power of the bean factory concept: You can achieve = so > much with it so easily. >=20 > BTW, I assume that the unfinished class in Spring's validation = package > that you mentioned is ValidationUtils. This class is meant to be a = simple > static utility class that provides low-level validation checks to = ease > Validator implementations. Don't confuse this with your Validator > implementations and their reusability across multiple layers. [John Cavacas]=20 That was the class that I was referring too and I realize it's not = finished. Thanks, John This communication is intended for the use of the individual(s) or = entity it was addressed to and may contain confidential and/or privileged = information. If the reader of this transmission is not the intended recipient, you = are hereby notified that any review, dissemination, distribution or copying = of this communication is prohibited. If you receive this communication in error, please notify the sender immediately and delete this = communication from your system(s) to which it was sent and/or replicated to. =A9 2002 Sapiens Americas Corp. |