Craig and company,

I'll comment some more below but I want to first explain what needs to
be set up and handled. I have an ArrayList of beans. Each bean in this
ArrayList also contains an ArrayList of String object. On my JSP I'm
using the nested tag (new to using it- bannana stuff very helpful
Arron) to create the dynamically created form. ( Picture a JSP that
was to display a dynamic list of cars and for each car there would be
list of particular styles you could pick from).

On Tuesday, July 16, 2002, 10:45:11 PM, Craig wrote:

CRM> If you're using request scope beans, a new instance gets created on every
CRM> request.  And I will bet that you probably have an initialization of this
CRM> array happening in your constructor, or in an initialization expression,
CRM> right?

     Yes, I believe so. A DTO is populated with the ArrayList of beans
     and then the DTO is converted to the DynaActionForm which is set
     into request scope. (The nested tag and display of the
     information on the page is working beautifully..problem is upon
     submission).


>>        What if the information in an ArrayList of beans that you want in a
>>        DynaActionForm is to first be populated by some database info.
>>        Do you need to first initialize it like a above to a bunch of
>>        nulls? If so what if the list size fluctuates (hence use of
>>        ArrayList) how do you know how many to initialize the ArrayList
>>        with?
>>

CRM> That's definitely a place where loading the arrays in the reset() method
CRM> makes sense.

     Ok, well what I've done is added this to the base class that my
     DynaActionForm (actually DynaValidatorForm) extends (Roman on
     this list was helping me with this) (20 is just an arbitrary
     number greater than the amount that would be displayed on the
     form):

public class UserDynaForm extends DynaValidatorForm {
    public void reset( ActionMapping mapping, HttpServletRequest request ) {
        ArrayList applicationGroups = new ArrayList();
        for (int i=0; i < 20; i++) {
            ApplicationGroupBean b = new ApplicationGroupBean();
            b.setRoles( new ArrayList() );
            applicationGroups.add(b);
        }
        set("applicationGroups", applicationGroups);
    }
}     

I then still have in my struts-config, for this form:
<form-bean name="userForm"
            dynamic="true"
            type="corporate.userAdmin.UserDynaForm">:
            <form-property name="applicationGroups" type="java.util.ArrayList"/>
            ....

The page will display the initial information fine. When I submit now,
however, the problem is it's trying to submit nulls. It's as if it
doesn't pick up what was selected on the JSP and this reset is wiping
out what was selected?

I'm sure I'm missing something simple so sorry for my ignorance. I
guess what is so odd is that when I switch to using a standard
ActionForm I don't have to override the reset and the page submits
fine.

Thanks for the help.

-- 

Rick
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to