If it helps, you can also nest beans on the ActionForm and refer to them with a dotted syntax.
In the html tags, you could then refer to name="billingAddress.street" or name="shippingAddress.street" where shippingAddress and billingAddress are properties on ContactForm, accessible through getShippingAddress() and getBillingAddress() -- Ted Husted, Husted dot Com, Fairport NY USA. -- Java Web Development with Struts. -- Tel +1 585 737-3463. -- Web http://www.husted.com/struts/ Joe Latty wrote: > > Thanks for the reply, I can see the sense in putting contact, address and > phone in one (Action) form. However how do you deal with one contact - one > to many addresses/phones? > > -----Original Message----- > From: twang7090 [mailto:[EMAIL PROTECTED]] > Sent: Monday, 4 February 2002 4:56 AM > To: Struts Users Mailing List > Subject: Re: Multiple beans > > Hi Joe, > > Please keep in mind that Struts's ActionForm is a map to a HTML Form object. > In a HTML page, you will define a form this way: > <FORM Name ="contactForm" ACTION="contact.do"> > <TEXT name="firstName> > <TEXT name="lastName> > </Form> > > In Jsp page, using the struts tags, we do this way > <html:form action="contact"> > <html:text property="firstName" /> > <html:text property="lastName" /> > </html:form> > Comparing this two, you find that the name of the form is specified > in the struts-config.xml file by the <action path="/contact" > name="contactForm" ...> > > The <action> tag in the struts-config.xml is the linker which > links the struts tags in the jsp to the ActionForm in the servlet. > > <html:form action="contact"> on the jsp page > causes the servelet created the contactForm as it is specified as > the name in the contact action. And this is the only ActionForm that > will be created for this action. (struts no any clue to see that you have > to have a address or phone form to be created). > > Now in your case, as a edit page of jsp, in the user interface part, > you'd better to put contact, address, phone in one form, and in your > servlet you may create different objects and save them separately. > > If you really need to separate them on the jsp page, you may end up using > three forms > in the same jsp page with three submit buttons(or one by the help of > javascript) > to submit them. In this case you will create three <action> in > struts-config.xml > and define three <html:form> in the jsp page. > > Hope this helps, > > Tony > > ----- Original Message ----- > From: "Joe Latty" <[EMAIL PROTECTED]> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > Sent: Sunday, February 03, 2002 9:32 PMSubject: Multiple beans > > > I am new to struts so excuse me if this is an incredibly naïve question, I > > have searched through the archive put am not sure what to even search on. > > > > I have multiple beans for a form an example would be contact.jsp where the > > ContactForm.java has the get and set methods for the contact e.g. > firstName, > > lastName etc, I have a bean AddressForm to handle the contact's address/s > > with get and set methods (adress1, address2 and so on) and a bean for the > > phone details (PhoneForm.java) with the corresponding phone information. > > > > <html:form action="contact"> > > <html:text property="firstName" size="30" maxlength="30" /> > > <html:text name="addressForm" property="address1" size="30" maxlength="30" > > /> > > <html:text name="phoneForm" property="phoneNumber" size="30" > maxlength="30" > > /> > > . > > > > In struts-config I have > > <action path="/contact" > > type="com.blah.blah.ContactAction" > > name="contactForm" > > scope="request" > > validate="true" > > input="/contact.jsp"> > > > > <form-bean name="contactForm" type="com.blah.blah.ContactForm"/> > > > > <form-bean name="addressForm" type="com. blah.blah.AddressForm"/> > > <form-bean name="phoneForm" type="com. blah.blah.PhoneForm"/> > > > > > > However the result is "Cannot find bean addressForm in scope null". > > > > If you could point me to some link with information it would be greatly > > appreciated. > > > > TIA > > > > Joe > > > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>