struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <>
Subject Re: How to populate a map of lists in an action form?
Date Wed, 04 May 2005 15:02:22 GMT
Daniel's question still has me perplexed? I'm still stumped on how to 
write the inputs for html and the proper ActionForm methods that would 
accomodate a situation where you needed to update Maps or Lists that are 
nested deeply. I understand how to do it when you have access methods to 
the Lists that are nested with beans - for example you have Company bean 
that has getDepartments which returns a list of Department beans and 
each dept bean has getEmployees. I can handle the above fine and it's 
how I typically orgainize by data. I'm still confused though how you 
handle a situation where someone simply added Lists to other Lists and 
you need to update the contents of the nested information.

For exmaple:

List bigList = new ArrayList();

List companiesList = new ArrayList();

List employees = new ArrayList();
employees.add(new Employee(...));
employees.add(new Employee(...));
employees.add(new Employee(...));

companiesList.add( employees )

List employees2 = new ArrayList();
employees2.add(new Employee(...));
employees2.add(new Employee(...));
employees2.add(new Employee(...));

companiesList.add( employees2 )

//do above for another companiesList2

bigList.add( companiesList1 );
bigList.add( companiesList2 );

How do you set up an input box to handle updating an Employee in a 
Company in the masterList

//2nd company in bigList, 3rd list of employees, 1st employee

Daniel Lobo wrote the following on 5/3/2005 6:19 AM:
> Hi,
> I have an action form with a map that can be accessed with getters and 
> setters. That map holds lists of elements. The problem is how to 
> populate that lists from the html form . I've tried with:
> <input name="elementsMap(0).[0]" value="foo">
> and
> <input name="elementsMap(0)[0]" value="foo">
> but doesn't work.
> However, i've implemented a new class child of ArrayList that adds this 
> two methods:
>    public List getList()
>    {
>        return this;
>    }
>      public void setList(List list)
>    {
>        clear();
>        addAll(list);
>    }
> And using this class in the map I can do from javascript:
> <input name="elementsMap(0).list[0]" value="foo">
> And the population of the ActionForm works properly. ┬┐Does somebody know 
> how to fix this problem without the use of this two "ugly" methods?
> Thanks.
> ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:


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

View raw message