Begin change

FileListElement class

The FileListElement class represents the contents of an Integrated File System directory.

Many file list element attributes can be retrieved or updating using methods that are provided in the FileListElement class. Some of the actions you can do with these methods are:

The following example creates a FileListElement object and displays the tag:

  // Create a FileTreeElement and set the text url so it calls another
  // servlet to display the contents of my FileListElement.
  // Create a URLParser object.
  URLParser urlParser = new URLParser(httpServletRequest.getRequestURI());

  // Create an AS400 object.
  AS400 system = new AS400(mySystem, myUserId, myPassword);

  // Create an IFS object.
  IFSJavaFile root = new IFSJavaFile(system, "/QIBM");

  // Create a DirFilter object and get the directories.
  DirFilter filter = new DirFilter();
  File[] dirList = root.listFiles(filter);
  
  for (int i=0; i < dirList.length; i++)
  {  

     // Create a FileTreeElement.
     FileTreeElement node = new FileTreeElement(dirList[i]);

     // Set the Icon URL.
     ServletHyperlink sl = new ServletHyperlink(urlParser.getURI());
     sl.setHttpServletResponse(resp);
     element.setIconUrl(sl);

     // Add the FileTreeElement to the tree.
     tree.addElement(element);
  }

  // When the user clicks on text url in the HTMLTree it should call another
  // servlet to display the contents.  It is here that the FileListElement
  // will be created.
  AS400 sys = new AS400(mySystem, myUserId, myPassword);

  // The FileTreeElment will properly create the text url and pass the
  // file and path information through the httpservletrequest.
  FileListElement fileList = new FileListElement(sys, httpservletrequest);

  // Create an array of optional html tags.  The %p and %f will be replace by the
  // appropriate path information and filename for each element in the FileListElement list.
  String[] options = new String[1];
  options[0] = "<a href=\"http://myWebServer/servlet/AnotherServlet?c=download&path=%p/%f\">Optional Action</a>";

  // Set the optional html tag(s).
  fileList.setOptions(s);

  // Output the content of the FileListElement.
  out.println(fileList.list());

The getTag() method above gives the output of the example once a user traverses the HTML tree down to /QIBM/ProdData/Http/Public/ and clicks on the jt400 directory link, the FileListElement will look something like the following:

Name Modified Type Size
com 06/09/2000 11:00:46 Directory
lib 07/05/2000 11:31:53 Directory
utilities 06/09/2000 11:01:58 Directory
MRI2924 06/09/2000 11:03:12 Directory
SSL56 07/01/2000 09:08:10 Directory
V4R5M0.LST 05/10/2000 10:35:06 File 38586 Optional Action
PXV4R5M01.LST 05/10/2000 10:35:13 File 38 Optional Action
CKSETUP.INI 05/10/2000 10:35:03 File 88 Optional Action
GTXSETUP.ini 05/16/2000 05:51:46 File 102 Optional Action
JT400.PKG 09/08/1999 04:25:51 File 19 Optional Action
OPNAV.LST 09/08/1999 04:26:08 File 16827 Optional Action
OPNAV.LVL 05/16/2000 05:51:31 File 19 Optional Action
OPV4R5M0.LST 09/08/1999 04:26:14 File 24121 Optional Action
OPV4R5M01.LST 05/16/2000 05:51:46 File 104 Optional Action
PROXY.LST 09/08/1999 04:26:00 File 4636 Optional Action
V4R5M01.LST 05/10/2000 10:35:09 File 33 Optional Action
PXV4R5M0.LST 09/08/1999 04:25:58 File 7101 Optional Action
READMEGT.TXT 05/16/2000 05:52:27 File 3480 Optional Action
READMESP.TXT 05/10/2000 10:35:10 File 4518 Optional Action
PROXY.LVL 05/10/2000 10:35:00 File 20 Optional Action
ACCESS.LVL 05/10/2000 10:35:19 File 15 Optional Action
ACCESS.LST 05/10/2000 10:34:57 File 15950 Optional Action
End change