I am using an action to prepopulate my action form with the data it needs.
Im my jsp I am using the nested tags to render the nested elements of the
form.

However when I submit the form, I was getting an exception having to do with
BeanUtils. My work around to that problem was to add the following method to
my form bean and call it from the constructor:

public void populateTestUser(){
                System.out.println("Entered populateTestUser()");
                //create three empty objects
                for(int i = 0; i < 3; i++){
                        TestUser tu = new TestUser();
                        testUser.add(tu);
                }
        }

As you can see it basically recreates 3 TestUser and adds it to testUser
which is an ArrayList. The number 3 is important because that is the number
of objects that are created in the action that prepopulates the form. In a
real world application we don't necessarily know the amount of objects that
could be created by a prepopulation action.

My reset looks like this:

public void reset( ActionMapping mapping, HttpServletRequest request ) {
                System.out.println("Entered reset method on form bean");
                
                if( this.testUser != null ){
                        System.out.println("testUser is not null");
                        System.out.println("The size of testUser is " +
testUser.size() );
                        for(int i = 0; i < testUser.size(); i++){
                                List cars =
((TestUser)testUser.get(i)).getCarsList();
                                for( int j = 0; j < cars.size(); j++){
                                        CarBean car = (CarBean)cars.get(j);
                                        car.setSelected(false);
                                }
                        }
                }
                else{
                        System.out.println("testUser is null");
                }
        }

Can anyone tell me why this won't work without the populateTestUser method
(shown above). I am not always going to know how many objects could exist in
an ArrayList so therefore I don't feel this is an elegant solution to this
problem.

Thanks in advance







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

Reply via email to