Re: Two Forms, Two Form Beans, One JSP
Ah, I think I get ya. Why don't you just make one great big form block containing both areas and any other non-form content inside? There's no restrictions on what can go in a "form", so you can put your entire page into form if you want. - M Michael Taylor TXE Systems, Inc. [EMAIL PROTECTED] Abdullah Jibaly wrote: No, I actually meant that Struts will only process and associate one form with the action processing that request, and therefore any validation, etc. So only one html form will get associated with the current ActionForm, even with session scope, although you may have several html forms in that page. Regards, Abdullah -Original Message- From: Michael Taylor [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 1:02 PM To: Struts Users Mailing List Cc: Andrew Tomaka Subject: Re: Two Forms, Two Form Beans, One JSP You can have multiple forms on the same page. I am using Tiles. I put some forms in the header/footer and they work just fine. I had to use different actions for the two forms, and I had to use session scope for one of them in order to retain state for it. Request scope is the reason for the one-form limit you are suggesting, right? Michael Taylor TXE Systems, Inc. [EMAIL PROTECTED] Abdullah Jibaly wrote: To simplify your code, I would have one ActionForm, and one processing action. Depending on which submit button or whatever is pressed I'd redirect to the correct page. By the way you can only have one struts action form per action and per jsp page. Regards, Abdullah -Original Message- From: Andrew Tomaka [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 9:26 AM To: user@struts.apache.org Subject: Two Forms, Two Form Beans, One JSP Hey all, I'm attempting to create a JSP that is made up of two forms. Each form needs a different form bean and is processed by a different action. The catch is that the first form returns back to the JSP and the action responsible for this needs the name attribute set to the Form Bean of the first form. When the JSP is loaded after the processing of the first form, both the form tags are assigned the name of the first Form Bean. Is it possible to assign Form Beans to a form instead of assigning them to an action? Thanks, ~ Andrew Tomaka - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two Forms, Two Form Beans, One JSP
On 7/7/05, Abdullah Jibaly <[EMAIL PROTECTED]> wrote: > No, I actually meant that Struts will only process and associate one form > with the action processing that request, and therefore any validation, etc. > So only one html form will get associated with the current ActionForm, even > with session scope, although you may have several html forms in that page. It is easy to use several independent HTML forms, if they submit user input to their respective actions, and then redirect to the same page (master page). Master page will be simply reloaded, possibly, with updated form data. Michael. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Two Forms, Two Form Beans, One JSP
No, I actually meant that Struts will only process and associate one form with the action processing that request, and therefore any validation, etc. So only one html form will get associated with the current ActionForm, even with session scope, although you may have several html forms in that page. Regards, Abdullah -Original Message- From: Michael Taylor [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 1:02 PM To: Struts Users Mailing List Cc: Andrew Tomaka Subject: Re: Two Forms, Two Form Beans, One JSP You can have multiple forms on the same page. I am using Tiles. I put some forms in the header/footer and they work just fine. I had to use different actions for the two forms, and I had to use session scope for one of them in order to retain state for it. Request scope is the reason for the one-form limit you are suggesting, right? Michael Taylor TXE Systems, Inc. [EMAIL PROTECTED] Abdullah Jibaly wrote: >To simplify your code, I would have one ActionForm, and one processing action. >Depending on which submit button or whatever is pressed I'd redirect to the >correct page. > >By the way you can only have one struts action form per action and per jsp >page. > >Regards, >Abdullah > >-Original Message- >From: Andrew Tomaka [mailto:[EMAIL PROTECTED] >Sent: Thursday, July 07, 2005 9:26 AM >To: user@struts.apache.org >Subject: Two Forms, Two Form Beans, One JSP > > >Hey all, > >I'm attempting to create a JSP that is made up of two forms. Each >form needs a different form bean and is processed by a different >action. The catch is that the first form returns back to the JSP and >the action responsible for this needs the name attribute set to the >Form Bean of the first form. When the JSP is loaded after the >processing of the first form, both the form tags are assigned the name >of the first Form Bean. > >Is it possible to assign Form Beans to a form instead of assigning >them to an action? > >Thanks, >~ Andrew Tomaka > >- >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] > > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two Forms, Two Form Beans, One JSP
I read this post several times. If I understood it, the key is this line: "...the action responsible for this needs the name attribute set to the Form Bean of the first form..." If I read this to mean you want a post to form A to update form B so that it has access to the state of submission to form A, then I would suggest that you use session scope and have the action for form A retrieve form B from the session and update it as needed. You can give it a reference to the other form if you like, or you can copy the data you nead from one form to the other. Is that what you are looking for? Cheers, Mike Michael Taylor TXE Systems, Inc. [EMAIL PROTECTED] Andrew Tomaka wrote: Hey all, I'm attempting to create a JSP that is made up of two forms. Each form needs a different form bean and is processed by a different action. The catch is that the first form returns back to the JSP and the action responsible for this needs the name attribute set to the Form Bean of the first form. When the JSP is loaded after the processing of the first form, both the form tags are assigned the name of the first Form Bean. Is it possible to assign Form Beans to a form instead of assigning them to an action? Thanks, ~ Andrew Tomaka - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two Forms, Two Form Beans, One JSP
You can have multiple forms on the same page. I am using Tiles. I put some forms in the header/footer and they work just fine. I had to use different actions for the two forms, and I had to use session scope for one of them in order to retain state for it. Request scope is the reason for the one-form limit you are suggesting, right? Michael Taylor TXE Systems, Inc. [EMAIL PROTECTED] Abdullah Jibaly wrote: To simplify your code, I would have one ActionForm, and one processing action. Depending on which submit button or whatever is pressed I'd redirect to the correct page. By the way you can only have one struts action form per action and per jsp page. Regards, Abdullah -Original Message- From: Andrew Tomaka [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 9:26 AM To: user@struts.apache.org Subject: Two Forms, Two Form Beans, One JSP Hey all, I'm attempting to create a JSP that is made up of two forms. Each form needs a different form bean and is processed by a different action. The catch is that the first form returns back to the JSP and the action responsible for this needs the name attribute set to the Form Bean of the first form. When the JSP is loaded after the processing of the first form, both the form tags are assigned the name of the first Form Bean. Is it possible to assign Form Beans to a form instead of assigning them to an action? Thanks, ~ Andrew Tomaka - 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]
Re: Two Forms, Two Form Beans, One JSP
This is what I've ended up doing for now. I have my one form bean for both forms since the data is related. What if the data isn't related though? Does Struts provide a simple solution or is just an area to hack around? I can accept the latter since it's expected when using a framework. Either way, thanks for all the help guys. I've gotten my forms in working condition with a design that I can put up with! ~ Andrew Tomaka On 7/7/05, Rick Reumann <[EMAIL PROTECTED]> wrote: > Andrew Tomaka wrote the following on 7/7/2005 12:00 PM: > > I imagine I've over complicated the problem, > > Yes, I think you are:) > > > My problem is that I have a "PreAction" to do the processing on the > > form. This requires the page to have the form bean assigned to it. > > Since I have two different forms doing two different things, I should > > have two different form beans, but I don't see how I can accomplish > > that. > > Here is a case where I don't believe you need to have these different > ActionForms. If you just need an "id" from one drop down list, simply > sumbit to the Action and pull that id out of the request. Nothing > forcing you to have to have ActionForm's hold everything. If you want an > ActionForm, make just one and provide... > > Integer searchID; > Integer programID; > > I don't feel this breaks desing principals since the intended use of the > ActionForm is to collect user input data from a "page" - in this case > you do have user data (in two lists) on one page. > > -- > Rick > > - > 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]
Re: Two Forms, Two Form Beans, One JSP
You could use frames for the bottom portion. Then you really *could* treat them as two separate pages because, well, they are! -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Thu, July 7, 2005 1:32 pm, Andrew Tomaka said: > Using a nested form bean may actually be a viable solution that I'll > have to look in to. Ideally though, I'd be able to treat the two > different forms as two separate pages that just happen to share the > same screen space. I guess that's the downside to using a framework: > you can't always get what you want. > > Anyway, I have a drawing of the flow that I'll upload when I am at > home. Unfortunately, the proxy here doesn't allow me to write to any > FTP space. > > ~ Andrew Tomaka > > On 7/7/05, Adam Hardy <[EMAIL PROTECTED]> wrote: >> Andrew, >> if the data being edited in the two forms are related, then for the >> child data you could use a nested bean as an attribute on the form. >> >> The parent data would remain as usual directly in the form. >> >> >> Adam >> >> Andrew Tomaka on 07/07/05 17:46, wrote: >> > I did consider using a single form bean for both forms, but it didn't >> > really sit well with me from a design stand point. We have two >> > different forms doing two different things so there should be two >> > different beans. Heck, if I had it my way, the two forms would be on >> > separate pages (wizard style), but the customer says otherwise. >> > >> > I do have an issue with using a single form. The top list is a list >> > of program ids. When a program id is selected, it brings up all the >> > different sheets for that program id. The user can then select a >> > sheet to edit, via radio button, and submit that request. With this >> > request, I need to pass the program id that was selected (via hidden >> > field). I can't rely on the program id in the drop down box because >> > if a user performs a search, changes the drop down box and then >> > selects a sheet to edit, we have a mismatch between the intended >> > program id to edit and the actual program id to edit (if that makes >> > any sense). >> > >> > ~ Andrew Tomaka >> > >> > On 7/7/05, Wendy Smoak <[EMAIL PROTECTED]> wrote: >> > >> >>From: "Andrew Tomaka" <[EMAIL PROTECTED]> >> >> >> >>>My problem is that I have a "PreAction" to do the processing on the >> >>>form. This requires the page to have the form bean assigned to it. >> >>>Since I have two different forms doing two different things, I should >> >>>have two different form beans, but I don't see how I can accomplish >> >>>that. >> >> >> >>There's nothing wrong with sharing one form across multiple Actions. >> I do >> >>it for an accounting reporting webapp. All of the forms ask for >> similar >> >>things, such as account numbers and dates, and this makes it simple >> for all >> >>the HTML forms to "remember" their selections. (The form is in >> session >> >>scope, so it happens naturally.) >> >> >> >>Just wanted to point out that there is no ironclad one-to-one >> relationship >> >>between HTML forms and form beans. >> >> >> >>-- >> >>Wendy Smoak >> >> >> >> >> >>- >> >>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] >> > >> > >> >> >> - >> 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] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two Forms, Two Form Beans, One JSP
Using a nested form bean may actually be a viable solution that I'll have to look in to. Ideally though, I'd be able to treat the two different forms as two separate pages that just happen to share the same screen space. I guess that's the downside to using a framework: you can't always get what you want. Anyway, I have a drawing of the flow that I'll upload when I am at home. Unfortunately, the proxy here doesn't allow me to write to any FTP space. ~ Andrew Tomaka On 7/7/05, Adam Hardy <[EMAIL PROTECTED]> wrote: > Andrew, > if the data being edited in the two forms are related, then for the > child data you could use a nested bean as an attribute on the form. > > The parent data would remain as usual directly in the form. > > > Adam > > Andrew Tomaka on 07/07/05 17:46, wrote: > > I did consider using a single form bean for both forms, but it didn't > > really sit well with me from a design stand point. We have two > > different forms doing two different things so there should be two > > different beans. Heck, if I had it my way, the two forms would be on > > separate pages (wizard style), but the customer says otherwise. > > > > I do have an issue with using a single form. The top list is a list > > of program ids. When a program id is selected, it brings up all the > > different sheets for that program id. The user can then select a > > sheet to edit, via radio button, and submit that request. With this > > request, I need to pass the program id that was selected (via hidden > > field). I can't rely on the program id in the drop down box because > > if a user performs a search, changes the drop down box and then > > selects a sheet to edit, we have a mismatch between the intended > > program id to edit and the actual program id to edit (if that makes > > any sense). > > > > ~ Andrew Tomaka > > > > On 7/7/05, Wendy Smoak <[EMAIL PROTECTED]> wrote: > > > >>From: "Andrew Tomaka" <[EMAIL PROTECTED]> > >> > >>>My problem is that I have a "PreAction" to do the processing on the > >>>form. This requires the page to have the form bean assigned to it. > >>>Since I have two different forms doing two different things, I should > >>>have two different form beans, but I don't see how I can accomplish > >>>that. > >> > >>There's nothing wrong with sharing one form across multiple Actions. I do > >>it for an accounting reporting webapp. All of the forms ask for similar > >>things, such as account numbers and dates, and this makes it simple for all > >>the HTML forms to "remember" their selections. (The form is in session > >>scope, so it happens naturally.) > >> > >>Just wanted to point out that there is no ironclad one-to-one relationship > >>between HTML forms and form beans. > >> > >>-- > >>Wendy Smoak > >> > >> > >>- > >>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] > > > > > > > - > 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]
Re: Two Forms, Two Form Beans, One JSP
Andrew Tomaka wrote the following on 7/7/2005 12:00 PM: I imagine I've over complicated the problem, Yes, I think you are:) My problem is that I have a "PreAction" to do the processing on the form. This requires the page to have the form bean assigned to it. Since I have two different forms doing two different things, I should have two different form beans, but I don't see how I can accomplish that. Here is a case where I don't believe you need to have these different ActionForms. If you just need an "id" from one drop down list, simply sumbit to the Action and pull that id out of the request. Nothing forcing you to have to have ActionForm's hold everything. If you want an ActionForm, make just one and provide... Integer searchID; Integer programID; I don't feel this breaks desing principals since the intended use of the ActionForm is to collect user input data from a "page" - in this case you do have user data (in two lists) on one page. -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two Forms, Two Form Beans, One JSP
Andrew, if the data being edited in the two forms are related, then for the child data you could use a nested bean as an attribute on the form. The parent data would remain as usual directly in the form. Adam Andrew Tomaka on 07/07/05 17:46, wrote: I did consider using a single form bean for both forms, but it didn't really sit well with me from a design stand point. We have two different forms doing two different things so there should be two different beans. Heck, if I had it my way, the two forms would be on separate pages (wizard style), but the customer says otherwise. I do have an issue with using a single form. The top list is a list of program ids. When a program id is selected, it brings up all the different sheets for that program id. The user can then select a sheet to edit, via radio button, and submit that request. With this request, I need to pass the program id that was selected (via hidden field). I can't rely on the program id in the drop down box because if a user performs a search, changes the drop down box and then selects a sheet to edit, we have a mismatch between the intended program id to edit and the actual program id to edit (if that makes any sense). ~ Andrew Tomaka On 7/7/05, Wendy Smoak <[EMAIL PROTECTED]> wrote: From: "Andrew Tomaka" <[EMAIL PROTECTED]> My problem is that I have a "PreAction" to do the processing on the form. This requires the page to have the form bean assigned to it. Since I have two different forms doing two different things, I should have two different form beans, but I don't see how I can accomplish that. There's nothing wrong with sharing one form across multiple Actions. I do it for an accounting reporting webapp. All of the forms ask for similar things, such as account numbers and dates, and this makes it simple for all the HTML forms to "remember" their selections. (The form is in session scope, so it happens naturally.) Just wanted to point out that there is no ironclad one-to-one relationship between HTML forms and form beans. -- Wendy Smoak - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two Forms, Two Form Beans, One JSP
Does the ActionForm for the bottom form only come into play when a selection is made in the upper form? If so, you could always instantiate the ActionForm yourself, populate it as appropriate in the Action that fires when that selection is made, shove it in request and deal with it manually. One exceedingly hacky way to do this, and I'm not sure it would work but it would be a neat experiment, is something like this: In the Action: -- MyLowerActionForm m = new MyLowerActionForm(); // Populate ActionForm as appropriate request.setAttribute("m", m); (of course you wouldn't use "m" as the key, but you get the idea!) Then in your JSP, have the upper form that is exactly like it probably is now, then, right before the lower form, add this line: <% request.setAttribute("", request.getAttribute("m")); %> is the key that the ActionForm would be found under if the lower form was the only one involved. Then code your form as usual. What I'm thinking is that you'd want to use the same usual tags for both forms, and allow Struts to do its thing as far as populating and such goes... this obviously won't work if the upper form requires a different ActionForm than the bottom, but if you overwrite the ActionForm that would be in request at that point for the upper form with the one you manually added to request for the bottom form, that might work. *IF* that does work, I'm not at all sure it's a good idea, but it's an intersting thought. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Thu, July 7, 2005 12:46 pm, Andrew Tomaka said: > I did consider using a single form bean for both forms, but it didn't > really sit well with me from a design stand point. We have two > different forms doing two different things so there should be two > different beans. Heck, if I had it my way, the two forms would be on > separate pages (wizard style), but the customer says otherwise. > > I do have an issue with using a single form. The top list is a list > of program ids. When a program id is selected, it brings up all the > different sheets for that program id. The user can then select a > sheet to edit, via radio button, and submit that request. With this > request, I need to pass the program id that was selected (via hidden > field). I can't rely on the program id in the drop down box because > if a user performs a search, changes the drop down box and then > selects a sheet to edit, we have a mismatch between the intended > program id to edit and the actual program id to edit (if that makes > any sense). > > ~ Andrew Tomaka > > On 7/7/05, Wendy Smoak <[EMAIL PROTECTED]> wrote: >> From: "Andrew Tomaka" <[EMAIL PROTECTED]> >> >> > My problem is that I have a "PreAction" to do the processing on the >> > form. This requires the page to have the form bean assigned to it. >> > Since I have two different forms doing two different things, I should >> > have two different form beans, but I don't see how I can accomplish >> > that. >> >> There's nothing wrong with sharing one form across multiple Actions. I >> do >> it for an accounting reporting webapp. All of the forms ask for similar >> things, such as account numbers and dates, and this makes it simple for >> all >> the HTML forms to "remember" their selections. (The form is in session >> scope, so it happens naturally.) >> >> Just wanted to point out that there is no ironclad one-to-one >> relationship >> between HTML forms and form beans. >> >> -- >> Wendy Smoak >> >> >> - >> 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] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two Forms, Two Form Beans, One JSP
I did consider using a single form bean for both forms, but it didn't really sit well with me from a design stand point. We have two different forms doing two different things so there should be two different beans. Heck, if I had it my way, the two forms would be on separate pages (wizard style), but the customer says otherwise. I do have an issue with using a single form. The top list is a list of program ids. When a program id is selected, it brings up all the different sheets for that program id. The user can then select a sheet to edit, via radio button, and submit that request. With this request, I need to pass the program id that was selected (via hidden field). I can't rely on the program id in the drop down box because if a user performs a search, changes the drop down box and then selects a sheet to edit, we have a mismatch between the intended program id to edit and the actual program id to edit (if that makes any sense). ~ Andrew Tomaka On 7/7/05, Wendy Smoak <[EMAIL PROTECTED]> wrote: > From: "Andrew Tomaka" <[EMAIL PROTECTED]> > > > My problem is that I have a "PreAction" to do the processing on the > > form. This requires the page to have the form bean assigned to it. > > Since I have two different forms doing two different things, I should > > have two different form beans, but I don't see how I can accomplish > > that. > > There's nothing wrong with sharing one form across multiple Actions. I do > it for an accounting reporting webapp. All of the forms ask for similar > things, such as account numbers and dates, and this makes it simple for all > the HTML forms to "remember" their selections. (The form is in session > scope, so it happens naturally.) > > Just wanted to point out that there is no ironclad one-to-one relationship > between HTML forms and form beans. > > -- > Wendy Smoak > > > - > 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]
Re: Two Forms, Two Form Beans, One JSP
From: "Andrew Tomaka" <[EMAIL PROTECTED]> > My problem is that I have a "PreAction" to do the processing on the > form. This requires the page to have the form bean assigned to it. > Since I have two different forms doing two different things, I should > have two different form beans, but I don't see how I can accomplish > that. There's nothing wrong with sharing one form across multiple Actions. I do it for an accounting reporting webapp. All of the forms ask for similar things, such as account numbers and dates, and this makes it simple for all the HTML forms to "remember" their selections. (The form is in session scope, so it happens naturally.) Just wanted to point out that there is no ironclad one-to-one relationship between HTML forms and form beans. -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Two Forms, Two Form Beans, One JSP
I had a similar situation and I used only one form, with the bottom part(result) inside a div, which is only visible depending on the action you took on the top part(search param part), otherwise it's invisible. It worked for me, even though it might not be the best solution. Thanks, -Original Message- From: Andrew Tomaka [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 12:00 PM To: Struts Users Mailing List Subject: Re: Two Forms, Two Form Beans, One JSP I imagine I've over complicated the problem, so I've taken a step back and am looking at it from the beginning again. The following are my basic requirements: When the user makes the first request, they are taken to a page with a drop down menu. This drop down menu is built from information stored in a database so I need to do some pre-processing. After that, the user chooses an option from the drop down menu and chooses to search. This returns a page that has the same form that was built in the first request on top and then a second form that lists the results of their drop down. This allows users to choose which of the results to edit. At this point the user can either use the drop down menu and have the bottom list rebuilt or choose a result to edit and proceed. My problem is that I have a "PreAction" to do the processing on the form. This requires the page to have the form bean assigned to it. Since I have two different forms doing two different things, I should have two different form beans, but I don't see how I can accomplish that. This is going to be a common thing to do throughout my entire application so I am hoping a simple design solution will pop up. Let me know if you need any other clarifications. I appreciate the help so far! ~ Andrew Tomaka On 7/7/05, Rick Reumann <[EMAIL PROTECTED]> wrote: > Andrew Tomaka wrote the following on 7/7/2005 10:26 AM: > > > I'm attempting to create a JSP that is made up of two forms. Each > > form needs a different form bean and is processed by a different > > action. The catch is that the first form returns back to the JSP and > > the action responsible for this needs the name attribute set to the > > Form Bean of the first form. When the JSP is loaded after the > > processing of the first form, both the form tags are assigned the name > > of the first Form Bean. > > I'm confused what you are trying to do. Possibly you can describe the > user requirements? > > > -- > Rick > > - > 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] - This email transmission and any accompanying attachments may contain CSX privileged and confidential information intended only for the use of the intended addressee. Any dissemination, distribution, copying or action taken in reliance on the contents of this email by anyone other than the intended recipient is strictly prohibited. If you have received this email in error please immediately delete it and notify sender at the above CSX email address. Sender and CSX accept no liability for any damage caused directly or indirectly by receipt of this email. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two Forms, Two Form Beans, One JSP
I imagine I've over complicated the problem, so I've taken a step back and am looking at it from the beginning again. The following are my basic requirements: When the user makes the first request, they are taken to a page with a drop down menu. This drop down menu is built from information stored in a database so I need to do some pre-processing. After that, the user chooses an option from the drop down menu and chooses to search. This returns a page that has the same form that was built in the first request on top and then a second form that lists the results of their drop down. This allows users to choose which of the results to edit. At this point the user can either use the drop down menu and have the bottom list rebuilt or choose a result to edit and proceed. My problem is that I have a "PreAction" to do the processing on the form. This requires the page to have the form bean assigned to it. Since I have two different forms doing two different things, I should have two different form beans, but I don't see how I can accomplish that. This is going to be a common thing to do throughout my entire application so I am hoping a simple design solution will pop up. Let me know if you need any other clarifications. I appreciate the help so far! ~ Andrew Tomaka On 7/7/05, Rick Reumann <[EMAIL PROTECTED]> wrote: > Andrew Tomaka wrote the following on 7/7/2005 10:26 AM: > > > I'm attempting to create a JSP that is made up of two forms. Each > > form needs a different form bean and is processed by a different > > action. The catch is that the first form returns back to the JSP and > > the action responsible for this needs the name attribute set to the > > Form Bean of the first form. When the JSP is loaded after the > > processing of the first form, both the form tags are assigned the name > > of the first Form Bean. > > I'm confused what you are trying to do. Possibly you can describe the > user requirements? > > > -- > Rick > > - > 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]
Re: Two Forms, Two Form Beans, One JSP
On 7/7/05, Andrew Tomaka <[EMAIL PROTECTED]> wrote: > Hey all, > > I'm attempting to create a JSP that is made up of two forms. Each > form needs a different form bean and is processed by a different > action. The catch is that the first form returns back to the JSP and > the action responsible for this needs the name attribute set to the > Form Bean of the first form. When the JSP is loaded after the > processing of the first form, both the form tags are assigned the name > of the first Form Bean. > > Is it possible to assign Form Beans to a form instead of assigning > them to an action? > > Thanks, > ~ Andrew Tomaka If you do not have prejudice against form bean with session scope, you can use Struts Dialogs and create two JSP Controls. Each JSP Control contains an action class and a form bean. For action class you either can directly use DialogAction, or you may have to subclass it. Include both controls (that is, their actions) into your JSP using . The submit request is sent directly to each control. You need to set up action mapping for each control to set the target/reload location. For the first control this would be you JSP page, in which you embed the controls. Struts Dialogs home page: http://struts.sourceforge.net/strutsdialogs JSP control how-to: http://struts.sourceforge.net/strutsdialogs/dialogaction-logincontrolsample.html Live demo of JSP control: http://www.superinterface.com/strutsdialog/embeddedmasterpage-tomcat.do In the live demo the "Sign In" box is a JSP control. The catch: if you use Tomcat, you cannot forward from action to JSP to render a control, Tomcat closes response writer right after forward. So you would need to design forward to JSP in regular way, then run your app, Jasper will generate Java source code for your JSP, then you need to copy that source code to your project. See the samples, they contain all needed code. This issue will be addressed in next SRV spec. It is a little hassle, but result worth it ;) Michael. -- Dialogs for Struts http://struts.sourceforge.net/strutsdialogs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Two Forms, Two Form Beans, One JSP
Andrew Tomaka wrote the following on 7/7/2005 10:26 AM: I'm attempting to create a JSP that is made up of two forms. Each form needs a different form bean and is processed by a different action. The catch is that the first form returns back to the JSP and the action responsible for this needs the name attribute set to the Form Bean of the first form. When the JSP is loaded after the processing of the first form, both the form tags are assigned the name of the first Form Bean. I'm confused what you are trying to do. Possibly you can describe the user requirements? -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Two Forms, Two Form Beans, One JSP
To simplify your code, I would have one ActionForm, and one processing action. Depending on which submit button or whatever is pressed I'd redirect to the correct page. By the way you can only have one struts action form per action and per jsp page. Regards, Abdullah -Original Message- From: Andrew Tomaka [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 9:26 AM To: user@struts.apache.org Subject: Two Forms, Two Form Beans, One JSP Hey all, I'm attempting to create a JSP that is made up of two forms. Each form needs a different form bean and is processed by a different action. The catch is that the first form returns back to the JSP and the action responsible for this needs the name attribute set to the Form Bean of the first form. When the JSP is loaded after the processing of the first form, both the form tags are assigned the name of the first Form Bean. Is it possible to assign Form Beans to a form instead of assigning them to an action? Thanks, ~ Andrew Tomaka - 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]
Two Forms, Two Form Beans, One JSP
Hey all, I'm attempting to create a JSP that is made up of two forms. Each form needs a different form bean and is processed by a different action. The catch is that the first form returns back to the JSP and the action responsible for this needs the name attribute set to the Form Bean of the first form. When the JSP is loaded after the processing of the first form, both the form tags are assigned the name of the first Form Bean. Is it possible to assign Form Beans to a form instead of assigning them to an action? Thanks, ~ Andrew Tomaka - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]