Can you register the exceptions that beanutils throws in the struts config???
-----Original Message----- From: Rick Reumann [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 08, 2003 4:57 PM To: Struts List Cc: model struts Subject: Model Layer question.. where to put BeanUtils.copyProperties (sort of long) After purchasing and reading Chuck's "Jakarta Struts" (O'Reilly -great book also) I was made aware of being able to declare Exceptions for your Actions in the struts-config file. Now that I'm aware that I could do that, it's possible to avoid the try/catch blocks that most of my dispatch action methods have. The question I have though is where to best do the form/DTO conversion provided by BeanUtils.copyProperties(). To give you some background my current architecture looks like this (using JDBC)... JSP --- dispatch Action --- calls a Service class method such as updateEmployee --- Service class gets appropriate DAO and calls DAO method (ie updateEmployee( DTO ) )( this really isn't a true DAO just mostly jdbc stuff in here) return to action and forward Before realizing about the handling Exceptions in the struts-config file, my DispatchAction methods usually all ended up with a try/catch block, including a generic Exception catch. If anything got in there it changed the forward name to the appropriate error page along with the resource message key to display the "Some problem message." Also in my dispatch Action method I would take the actionForm and convert it to the appropriate DTO by the use of BeanUtils.copyProperties. I then called the appropriate service method passing in this DTO. (ie service.updateEmployee( employeeDTO ) ). Problem is now that copyProperties throws two Exceptions which didn't seem to bother me as much before since I always had a try/catch in the action anyway. Now I'm starting to think that I should move the BeanUtils.copyProperties outside of the Action and do that somewhere else. I don't really like the idea of passing the ActionForm into the service layer since that couples the service layer to Struts, although maybe that's not too big of a deal. I'm starting to think maybe the best idea would be to create a separate class that calls the BeanUtils.copyProperties() and also throws it's own Exception that I can declare in the struts-config file. Something like... PropertyCoverter { copyProperties( Object a, Object b) throws MyException { try { BeanUtils.copyProperties( a, b ); } catch(Exception e ) { //log error throw new MyException(); } } } I was thinking if I do the above I could get the error handling I need without the try/catch in the Action necessary for coverting the form to the DTO? Thanks for any comments. -- Rick mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

