struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mainguy, Mike" <>
Subject RE: FormBean question...
Date Tue, 16 Sep 2003 11:35:08 GMT
This is by design.  If you want to ensure this will not happen, you need to
set all the values to "" or null beforehand for fields that should be empty.
The short answer is "change the field name".  Especially if you are going to
store data in a form in the session you will have a big mess on your hands
if you have overlapping field names in multiple forms.

My $.02...

-----Original Message-----
From: alanbrown [] 
Sent: Tuesday, September 16, 2003 2:18 AM
Subject: FormBean question...

I am using 2 different beans to populate 2 forms on 2 pages.  However some
of the fields have the same names, as both customers and contacts have
addresses and both companies and contacts have descriptions and notes
associated with them.  After entering a company the user is prompted to
enter some details of a person within that company with, hopefully, some of
the form already filled out (the address fields have default values for
instance taken from the company info that was just entered).  However the
description field and the notes field are also filled out with the values
entered in the addCompany.jsp page and this should not happen.
This seems very strange as I've got 2 different formBeans used to populate
the fields.  Here are the relevant parts of the strutsconfig file.
            <forward name="Success" path="/"/>
            <forward name="Failure" path="/add/company.jsp"/>
            <forward name="next" path="/add/contact.jsp"/>
As you can see they are using different types of form so I find it very odd
that the description and note fields are pre populated as well as the
address.  The way I've tried to populate the fields I want pre-polulated is
by having the following code at the end of my addCompanyAction class
        ContactForm contactForm = new ContactForm(new
Integer(companyId).toString(), companyForm.getAddress());
        request.setAttribute("addContactForm", contactForm);
        return mapping.findForward("Success");
and then, when forwarded to the prepareAddContactAction class, have the
following code.
    public ActionForward executeAction(ActionMapping mapping,
                                       ActionForm form,
                                       HttpServletRequest request,
                                       HttpServletResponse response,
                                       UserContainer container) {
        ContactForm contactForm =
        //if "addContactForm" is not null in the request scope then we
should use it to populate our form.
        form = contactForm == null? form : contactForm;
        return mapping.findForward("next");
But somehow I'm getting all the companyForm's fields populating the
contact form.   IE. I put a company description in the addCompany jsp
and it shows up as a contact description in the addContact jsp, and I don't
pass the description field to the contactForm.
Is there something I'm not understanding about the struts architecture?
Help is, of course, greatly appreciated.

To unsubscribe, e-mail:
For additional commands, e-mail:

This message and its contents (to include attachments) are the property of Kmart Corporation
(Kmart) and may contain confidential and proprietary information. You are hereby notified
that any disclosure, copying, or distribution of this message, or the taking of any action
based on information contained herein is strictly prohibited. Unauthorized use of information
contained herein may subject you to civil and criminal prosecution and penalties. If you are
not the intended recipient, you should delete this message immediately.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message