On 7/18/05, Rick Reumann <[EMAIL PROTECTED]> wrote: > I'm still not totally clear where the problem is, since I'm not sure > what Session has to do with the initial setup of the form.
The difference is unobvious, I admit, but this is what I was thinking of: If I use a session bean, I can do some sort of setup (from an Action) on its initial creation, including creating the list of contained objects. That can't happen if it's in request scope because there is no chance to invoke the setup before the bean is populated from the request. > 1) A problem when you submit the form and getting 'index' problems > showing up in the logs? More than showing up, the submit was trying to populate the bean with indexed properties but the list containing the indexed properties was of size zero. The answer to the problem was given by the previous posters. Thanks guys. What made the difference was the Wiki page section (BeanUtils Indexed Properties Issue) pointing out that there is a bug in JDK 1.4 which prevents the solution of writing your own getXXX( int ndx ) property. I had done that (in desperation) and when that didn't work either, I threw up my hands and wrote the list. I felt that it _should_ have worked and when it didn't I just assumed my understanding of the situation was inadequate and gave up. I'm delighted to find out that the problem is in the implementation and not in my mental picture of how this whole thing works. > I'm confused because you mention "But, of course, a newly created form > won't know how many elements are in the form so it can't pre-populate > the collection with beans to be filled in." This statement confused me > because you seem to be implying it works when it's in Session which > doesn't make sense since even with a Session scoped form you still need > to some initial population somewhere. But you can do that once, before all this other stuff takes place. I realize that wasn't an obvious inference but that's what I meant. > Typically I feel you should always go to some sort of "setUp" action or > dispatch method BEFORE you ever forward to a form. But doesn't that go away in request scope when the form is submitted back to the Action? Doesn't a new form get created and populated from the HTML? It sure looks like that's what's happening to me. > For the two problems listed above the link Naill posted is good > http://wiki.apache.org/struts/StrutsCatalogLazyList (and I just recently > added to that link the way I like to do it). I came up with another solution which might be worthy of consideration. Instead of using arrays, extend a list with the desired get( int ) method and use that list instead: public class SkillActionForm extends ActionForm { protected List skills = new LazyArrayList(); public class LazyArrayList extends ArrayList { public Object get( int index ) { while (size() <= index) add( new SkillBean() ); return super.get( index ); } } } This is the solution I eventually adopted (successfully) but I have a fondness for nested classes which others may not share. Anyway, thanks to all, I've gotten past the problem with an increased understanding of the intricacies of this here Struts stuff. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]