Hello, We're transitioning from a Struts 1.x and Tiles development environment to Struts 2 and Sitemesh, and I need some help getting around some of the differences. Here's what I'm planning so far. I want to have an abstract BaseAction that extends ActionSupport. Since we are no longer using Tiles, we can't count on using Tiles Controller classes to prepare a page for display -- for example, retrieving the contents of drop down lists from the database. In my BaseAction, I have overridden the execute() method to call a "lifecycle" method called prepareAction() that is meant to be an extension point for subclasses to retrieve any data the is needed to display the page. For example, let's say there's a drop-down select box on a page, and its contents come from a database. A concrete implementation of BaseAction should override prepareAction() to retrieve the list items for the drop down list. Now, here's where things get sticky: Assume the page above is displayed. The user enters some form data and posts the page. However, there are some validation errors. Struts 2 will automatically redisplay the page.... but will the drop-down list be populated with list items, or will it be empty? In the Struts 1.x/Tiles world, where we have a Tiles Controller backing the JSP, the list items would be repopulated by the Controller. But with Tiles no longer in play, what will repopulate the list? I'm pretty sure that the prepareAction() method that was used when the page is first displayed will not be called when there are validation errors, resulting in an empty drop-down list. So, here are my questions: 1. Is my idea to have a BaseAction that provides an extension point for subclasses, where things like database access should occur, a bad idea? 2. What is the recommended way to repopulate drop-down selects after a validation error, if the list items need to be retrieved from a database? Thank you!! -Ryan
This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.