[StrutsCatalog]: *Check Actions for preconditions* The {noformat} execute {noformat} method in the Action is a key hotspot in the framework, and may be realizing several different API contracts. To be sure all the contracts are being met, provide a general error catching routine for your Actions. This method can look for any number of preconditions, such as whether there is a form bean for the expected subclass. If these preconditions fail, in most cases a runtime exception should be thrown. A broken contract is usually a programming error that needs to be fixed without delay. The Action should expose the error so that it can be quickly corrected. \{ { \{ A common case is checking for a null form bean. If an Action expects an [ActionForm] bean, then its API contract with the [ActionMappings] should require that a particular [ActionForm] bean, or subclass thereof, be named in the [ActionMapping]. The Action's contract with the controller is that it will always instantiate the bean before the Action is called. If either contract is broken, the application should expose a null pointer exception, or other runtime exception, so that the programming error is fixed and the misunderstanding resolved. Whether an Action expects an [ActionForm] bean should be specified in its Javadoc. \} } \} --TedHusted ---- Comments:
  • No labels