More (application-level) code isn't needed... it's just a question of making it declarative rather than programmatic, which is how so much of Struts already is.
Here's an example from the example app posted to the Bugzilla ticket I referenced (ticket # 33935 if you want to download it and try it)... I wrote a class SetupClass1. It contains three methods, setupMethod1(), setupMethod2() and setupMethod3() (I don't win any contests for creative naming today!). Now... let's say that setupMethod1() reads from a database and creates an ArrayList that is used to populate a dropdown. Let's further say that this dropdown is on a couple of pages in the app. Clearly it makes sense to have this "setup" code in a separate class. Now, as you were saying, you could just use this class from the Actions manually, that works fine, and plenty of people do that. But, it's extra code, and redundant code if used in more than one Action, even if the redundant code amounts to: SetupClass1.setupMethod1(request); (assuming its a static method). Instead, my proposal, and what I posted to Buzilla accomplishes this, is to allow this: <action path="/page1" type="com.omnytex.setupexample.action.TestAction"> <forward name="defaultForward" path="/result.jsp"> <setupItem setupClass="com.omnytex.setupexample.setups.SetupClass1" setupMethod="setupMethod1" /> </forward> </action> So now, whenever that forward is returned the method will be executed. It is passed request, so it does whatever it does, presumably sticks the ArrayList in request as per the example, and everything else goes on as before. It's just a declarative approach to the programmatic solution. Now, the code I submitted allows you to put the <setupItem> element within forwards as shown here (that's what I meant by at the forward-level). You can ALSO put it at the mapping level, and those items get executed BEFORE execute() is called (as opposed to after, in the case of the forward-level elements). In addition, you can add <setupItem>s to global forwards just the same. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Wed, March 9, 2005 2:20 pm, Shey Rab Pawo said: > On Wed, 9 Mar 2005 14:07:04 -0500 (EST), Frank W. Zammetti > <[EMAIL PROTECTED]> wrote: >> But do you see the point in setup functions *outside* an Action's code >> that occurs on the forward-level? Meaning, once an Action returns a >> forward, do some setup based on what forward was returned? > > > Yes. I do, I think, depending on what "that occurs on the > foward-level" means. If there is a generic setup tied to a forward, I > would write a setup class with a setup method that returns the > ActionForward that is relevant and leave all other complications out > of the picture. I don't understand the point of the complications. > This seems to be a regular sort of thing that does not need the > complications to me. > >> maybe there is setup that you >> want to perform regardless of which forward is returned by the Action... >> yes, it happens before the Action is executed, but it hardly matters >> whether it happens before or after execute() is called, as long as it >> happens regardles of the forward returned is the pertinent point). > > I would then just write a class that does the setup and whenever that > logic is needed use the class. I just don't see why this is not all > easy given the present code and wonder why more is needed. > > I don't see the need for the extra complications. What is the problem? > > -- > No one ever went blind looking at the bright side of life. > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]