Hi all I have a JSP Page with more than one form. Because I reuse this forms in other JSP Pages, I need more than one form and can not combine them to one form. Now I want to set the data of my Business Objects to this forms. My question now: How can I set the Business Objects to the forms? Of course I wane do this in the perform method of the Action class. Do I have to create the forms for this request by my own or do I have to set the Business Objects in the request and get the data back in the constructor when the forms are created:-(? I have to use struts 1.0 Many thanks for good idees Andr�
I think you have a real problem here. Multiple forms on a single page are a nightmare for users. Imagine I enter some data in a field on form A, then enter some other data in a field on form B, then click one of the two submit buttons. What happens? Only part of what I have entered is sent to the server, and the rest is silently discarded by the browser. Yuck! Please consider generating a single "form" tag in the enclosing page, then just the form fields in the included pages. That will combine all the fields into a single form, and make all your other problems go away. If you need to re-use the forms in other pages, wrap them in a simple page with just the form declaration, or make the generation of the form declaration optional based on a parameter or Request attribute.
There are times when, due to the quirks of HTML, you HAVE to provide more than one form on a page, but, as Frank says, you can get in a lot of trouble unless you've made it graphically clear what gets sent and when. In Struts, you have the Form Bean. Although Form Beans are (more or less) "models" in the model/view/controller architecture, they are not neccesarily the actual final business objects. A Form Bean may be standing as a proxy for multiple business objects. And in this way, you can have a single HTML form that's mapping to multiple objects in a way that resembles multiple forms. You may find it useful to use the same form bean on multiple JSPs and/or to use logic tags to control what Form Bean items are displayed in a view. Then, as part of your Action processor, you can direct the Form Bean's contents to your actual Business Objects as required.
Customer surveys are for companies who didn't pay proper attention to begin with.