Hi,
I have a loop, which iterates over an arraylist, and when certain conditions are met, it calls a method with some parameters, which returns a new arraylist.
As I may be calling this many time (for each iteration of my loop), I end up with many different arraylists. Is there any easy way of "glue"ing them all together. My goal is to end up with one list.
Note that the [blue]getUserIDInGroups()[/blue] will always return an arraylist. At present, the code above gives me an array of arrays so to speak.
I'm not sure if it's possible/practicle to expand the results from [blue]getUserIDInGroups()[/blue] before storing it.
Ultimately, my goal is to stuff my big single list in the request scope so I can render it in a JSP. Maybe I should be using a vector or a collection or something <shug>.
Any feedback would be appreciated.
I have a loop, which iterates over an arraylist, and when certain conditions are met, it calls a method with some parameters, which returns a new arraylist.
As I may be calling this many time (for each iteration of my loop), I end up with many different arraylists. Is there any easy way of "glue"ing them all together. My goal is to end up with one list.
Code:
ArrayList al = new ArrayList();
try {
LDAPUtility lu = new LDAPUtility();
// List of my roles
ErmUserBean eb = (ErmUserBean) request.getSession().getAttribute("userBean");
ArrayList rolesList = eb.getExtranetRoles();
for (Iterator iter = rolesList.iterator(); iter.hasNext();) {
String role = (String) iter.next();
// Is this role valid to access this report ?
if(reportGrps.contains(role)){
//TODO Concatenate Arraylists with each iteration.
al.add(lu.getUserIDInGroups(role));
}
}
}
Note that the [blue]getUserIDInGroups()[/blue] will always return an arraylist. At present, the code above gives me an array of arrays so to speak.
I'm not sure if it's possible/practicle to expand the results from [blue]getUserIDInGroups()[/blue] before storing it.
Ultimately, my goal is to stuff my big single list in the request scope so I can render it in a JSP. Maybe I should be using a vector or a collection or something <shug>.
Any feedback would be appreciated.