Actually I just realized part of the problem below is/was is that even
using the standard ActionForm I can't seem to get the nested ArrayList
stuff to take upon submission unless I give the form session scope.

I'm sure this question has been answered before so I'll look in the
archives ( although I must admit the searching ability on the archives
for this struts list is not the greatest )

If someone does have comments don't hesitate to send them.
Thanks
Rick

On Wednesday, July 17, 2002, 11:24:10 AM, Rick wrote:

RR> Craig and company,

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

RR> 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?

RR>      Yes, I believe so. A DTO is populated with the ArrayList of beans
RR>      and then the DTO is converted to the DynaActionForm which is set
RR>      into request scope. (The nested tag and display of the
RR>      information on the page is working beautifully..problem is upon
RR>      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.

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

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

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

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

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

RR> 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