Hi Bill, thanks for the advice.
See below for comments to your mail: > -----Ursprüngliche Nachricht----- > Von: Bill Keese [mailto:[EMAIL PROTECTED] > Gesendet: Montag, 15. November 2004 01:21 > An: Struts Users Mailing List > Betreff: Re: using multiple action forms in one action. Best practice? > > > Martin Kindler wrote: > > >in my application I have a rather complex object to deal > with. I have > >split the process in several jsps (JSP1, ..., JSPn) using different > >ActionForms (AF1, ..., AFm)... > > > >2. merge all ActionForms to one big mega ActionForm > >Pro: works > >Con: no modularization; if I need to use one (partial) ActionForm in > >another place, I have to take everything or replicate the needed part > > > > > You are talking about a wizard, right? IE, one logical form > split over > several JSP pages. Technically speaking one could probably call it a wizard, but conceptually I don't see it like one. I would like to have several modules ("forms") for getting input from a user, which should play together, possibly in various contexts. I am dealing with geographical objects, so I have some base information (id, textual description, region, etc.). Then I want to add several "access points" to an object, which are effectively addresses with a name. These addresses come from a data base with thousands of addresses while an object can just have a few access points. So I have a JSP (say JSP1) with a form (say AF1) to acquire the base information. From this JSP I want to access a (hopefully) generic module to get the access points. This "module" has to get some information (e. g. a region to prefilter the addresses or access points already existing) from JSP1. The address module (in the view another JSP , JSP2 using another action form AF2) accesses the data base, presents the addresses to the user and lets him select the right ones. On finish the selected addresses are transferred to the object and presented in JSP1 again where the user can end the editing process causing the objects to be saved. This address module might be useful in other places of my application where I need to select some addresses. Also I need a number of supporting information (e.g. the filter specification) which is not needed to be known by JSP1. Therefore I do not like putting all the information into one big ActionForm. I could take the necessary information from AF1 to some POJO (or bean) on model level (or controller level) and transfer it to AF2. This is probably the "cleanest" solution but means to split each action into two, just to do the data transfer. My current solution simply accesses both action forms, AF1 and AF2 (getting the one not available as the "form"-parameter by MyForm mf = (MyForm)session.getAttribute("AFi"); but my feeling is that this is not really good style. >In that case, I think you should just use one > ActionForm with the data from all the JSP pages. I think the manual > says something to the same effect. You can either: > > 1. make the ActionForm a session level form (see > http://www.ajug.org/archive/ajug-members/10203/msg00066.html) > 2. (or) make the ActionForm request level, in which case > all your JSP > pages must have hiden fields representing the data that has > already been > input on the previous JSP pages. > > I'm not sure how to do the forwarding from one JSP page to > the next page > (preserving the contents of the partially filled ActionForm). Do you > need to write a dummy Action for each JSP page, or can > you/should you > forward directly from one JSP page to the next one, like > this? Try it > out and let me know, if you can. > > <action > path="/wizardPage1" > name="wizardForm" > forward="/wizardPage2.jsp" > </action> > <action > path="/wizardPage2" > name="wizardForm" > forward="/wizardPage3.jsp" > </action> I tested it. It works, but I can't use it, as I have to do a bit more complex things (e. g. data base access) during the switch to the second form. > > Bill > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]