Q1) compile time checking?
If you use ActionForms, you have distinct types associated with each ActionForm property. That means when Struts populates the ActionForm, it handles conversions for you. IOW, the framework does type conversions based on the underlying types of the properties (there are well defined rules within Struts to determine how that happens). This is what I referred to as "compile time checking", although that term is a little misleading here -- it's a leftover term from a previous, similar problem.
When you use maps, everything goes into the map as a String
, meaning that: All values come back to you as a String, and you have to write your own conversionsIt is possible to mis-type the name of a property, and thus the framework won't populate the form correctly
In some situations, you don't know all the properties up front, so you have to use dynamic properties. Struts also has a mechanism called "DynaForms" which offers some of the advantages of both the above approaches.
Q2) What are the business rules interfaces? Please elaborate. Are they something that Struts provide or your customized interfaces?
This is a de-coupling technique that is widely used by Struts developers. Instead of having your entities directly sub-class ActionForms (bad practice because you are mixing Framework code with your model (the entities)), you create interfaces that include all the properties of the entity (called Business Rules Interfaces). Then, your actual entity classes and the ActionForm both implement the interface, and the ActionForm encapsulates one of your entity classes. The interface creates a contract between the business rules and the ActionForm, and the ActionForm proxies the property values to the encapsulated entity.
This is a relatively advanced use of ActionForms, but it offers some great advantages from a design standpoint because the entities are completely decoupled from the frameworkthe interface ensures that both the ActionForm and the entity agree on what information is needed
Hope that helps.
Neal Ford<br />Author, <i>Art of Java Web Development: Struts, Tapestry, Commons, Velocity, JUnit, Axis, Cocoon, InternetBeans, WebWork</i><br /><a href="http://www.nealford.com" target="_blank" rel="nofollow">www.nealford.com</a>