Skip to Content
0
Former Member
Jun 01, 2009 at 08:26 PM

Dynpage with Multidimensional Array

33 Views

I have a Dynpage project which successfully displays a list of Subfolders in a folder. I would like it to also list the SubFolders for the SubFolders. To do this I am using a multidimensional array.

However when I try to set the value of the array I always get a Portal Runtime error. Can someone please look at this and tell me where I am going wrong?

//Loop through the Root folder and set the display fields
while(it.hasNext())
{	
          IResource res = it.next();
          Category[iCount]=res.getName();	
					
          //Set the Path for the Category Folder
          String sPath = folderBean.getPath()+"/"+Category[iCount];
          RID subpathRID = RID.getRID(sPath);
					
          //Set the variables for creating the SubFolder list
          IResourceFactory oSubFactory = ResourceFactory.getInstance();
          IResource resourceSub = oSubFactory.getResource(subpathRID,resourceContext);
          ICollection collectionSub = (ICollection) resourceSub;	
          IResourceListIterator itSub = collectionSub.getChildren().listIterator();
          int iSubFolderCount = collectionSub.getChildrenCount(false,false,false);
					
          //Set the Variables for holding the data
          String SubCategory[][] =new String[iFolderCount][iSubFolderCount];
          int SubCount[] =new int[iFolderCount];	
					
          //Loop through the subFolders and set the display fields
          while(itSub.hasNext())
          {	
              IResource Subres = itSub.next();
              SubCategory[iCount][iSubCount]=Subres.getName();
              iSubCount++;
          }				
          iCount++;
}

//Set the Bean Fields
folderBean.setCategory(Category);
folderBean.setFolderCount(iCount);	

It all works great until I add in this line:

SubCategory[iCount][iSubCount]=Subres.getName();

Then I get the portal runtime error - so obviously I am not setting this correctly? This is how I have handled multidimensional arrays in other projects but I am at a loss for why it is not working here?