Asleson, Ryan wrote: > I'm familiar with the Struts 2 Preparable interface, but I don't > like this because prepare() is always called -- even on form posts
Do you have one Action with two public methods that are called by Struts 2? For example view() and submit() methods? If that's the case, I can understand why you wouldn't want prepare() called when submit() is called. To solve that, just rename your prepare method to prepareView(), and it will only run when view() is called. If you are not using multiple public methods in one Action, and each Action just implements the execute() method, I'd assume you have separate Actions for viewing and submitting, let's call them ViewAction and SubmitAction. In this situation, make your ViewAction implement Preparable, but don't have SubmitAction implement it. Am I way off base here? I personally like Preparable since the method gets called even when there is a validation error. So you have a place to put code that you want run both on initial display and on after a POST with validation errors. Brad Cupit Louisiana State University - UIS -----Original Message----- From: Asleson, Ryan [mailto:[EMAIL PROTECTED] Sent: Monday, June 23, 2008 8:36 AM To: Struts Users Mailing List Subject: Struts 2: Providing Tiles Controller-like Functionality Hello, We're moving from a Struts 1.x with Tiles development model to Struts 2 and Sitemesh. One thing we miss with from Tiles is the ability to back a JSP with a Controller. The Controller guaranteed that whenever a JSP was rendered, certain behavior was executed to prepare data for the JSP. For example, the loading of data for drop-down select boxes was often placed in the Controller. Now that we're not using Tiles we can no longer use Controllers, so I'm wondering if Struts 2 has any sort of equivalent functionality. I'm familiar with the Struts 2 Preparable interface, but I don't like this because prepare() is always called -- even on form posts, which in my case, is at best an unnecessary database hit (or hits), and at worst can cause confusion with what was actually posted from the page vs. what was retrieved from prepare(). If it helps any, we have a 1:1 mapping between an Action and a JSP, including a naming convention: MyFavoriteAction maps to myFavorite.jsp. Any thoughts or comments? 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. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]