Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
Originally posted by Srikanth Shenoy:
BuildLoanListAction --> loanlist.jsp --> DeleteLoanAction --> BuildLoanListAction --> loanlist.jsp.
Here's how I'd refactor:
Take code from BuildLoanListAction and put into LoanListBuilder helper class. BuildLoanListAction uses LoanListBuilder to get a list of loans, forwards to loanlist.jsp DeleteLoanAction uses LoanListBuilder to get a list of loans,
forwards to loanlist.jsp
Also, it is a common practice to lump CRUD operations into one Action class. Chaining to such a class often results in a lot of unnatural conditional logic being written to ensure the proper routing of the request. This just adds a lot of unnecessary complexity to the Action class code.
Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
Kevin Judd, SCJP
Originally posted by Karthik Guru:
Cant we put the actual deletion and retreival logic in the helper class and still do action chaining? I mean the Delete and Retreival action still use the helper to execute business logic. The DeleteAction does what it is supposed to ie delete the entity and the Retreival action continues to do its job of 'getting'.
When you say complex code, are you implying that the action that features earlier in the chain might have to populate some additional context information for the one that follows it?
George Franciscus<br />george.franciscus@nexcel.ca<br /><a href="http://www.nexcel.ca" target="_blank" rel="nofollow">http://www.nexcel.ca</a><br /><a href="http://www.manning.com/franciscus" target="_blank" rel="nofollow">http://www.manning.com/franciscus</a>
Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
Don't get me started about those stupid light bulbs. |