com.ibm.as400.util.html
Class FileListElement

java.lang.Object
  |
  +--com.ibm.as400.util.html.FileListElement

public class FileListElement
extends java.lang.Object
implements java.io.Serializable

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

This example creates an FileListElement object:

  // Create a HTMLTree object.
  HTMLTree tree = new HTMLTree(req);
  

// 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 element = new FileTreeElement(dirList[i]);

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

// Set the text url so it calls another // servlet to display the contents of the FileTreeElement. ServletHyperlink tl = new ServletHyperlink("/servlet/myListServlet"); tl.setTarget("listFrame");

// Set the TextUrl for the FileTreeElement. element.setTextUrl(tl);

// 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%p%f?c=download\">Optional Action</a>";

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

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

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

FileTreeElement objects generate the following events:

See Also:
DirFilter, Serialized Form

Constructor Summary
FileListElement()
          Constructs a default FileTreeElement object.
FileListElement(AS400 system, javax.servlet.http.HttpServletRequest request)
          Constructs an FileTreeElement with the specified system, and request.
FileListElement(AS400 system, javax.servlet.http.HttpServletRequest request, HTMLTable table)
          Constructs an FileTreeElement with the specified system, request, and table.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 javax.servlet.http.HttpServletRequest getHttpServletRequest()
          Returns the Http servlet request.
 java.lang.String[] getOptions()
          Returns the array optional html tags used in the FileListElement object.
 AS400 getSystem()
          Returns the AS/400 system.
 HTMLTable getTable()
          Returns the HTMLTable.
 java.lang.String list()
          Returns a string containing the list of files and directories in the path defined in the HttpServletRequest.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the PropertyChangeListener from the internal list.
 void setHttpServletRequest(javax.servlet.http.HttpServletRequest request)
          Sets the Http servlet request for the element.
 void setOptions(java.lang.String[] options)
          Sets one or more optional html tags.
 void setSystem(AS400 system)
          Set the AS/400 system.
 void setTable(HTMLTable table)
          Set the HTMLTable to use when displaying the file list.
 void sort(boolean sort)
          Sorts the list elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileListElement

public FileListElement()
Constructs a default FileTreeElement object.

FileListElement

public FileListElement(AS400 system,
                       javax.servlet.http.HttpServletRequest request)
Constructs an FileTreeElement with the specified system, and request.
Parameters:
system - The AS/400 system.
request - The Http servlet request.

FileListElement

public FileListElement(AS400 system,
                       javax.servlet.http.HttpServletRequest request,
                       HTMLTable table)
Constructs an FileTreeElement with the specified system, request, and table.
Parameters:
system - The AS/400 system.
request - The Http servlet request.
table - The HTML table.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange method is called each time the value of any bound property is changed.
Parameters:
listener - The PropertyChangeListener.
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)

getHttpServletRequest

public javax.servlet.http.HttpServletRequest getHttpServletRequest()
Returns the Http servlet request.
Returns:
The request.

getOptions

public java.lang.String[] getOptions()
Returns the array optional html tags used in the FileListElement object.
Returns:
The optional html tags.

getSystem

public AS400 getSystem()
Returns the AS/400 system.
Returns:
The system.

getTable

public HTMLTable getTable()
Returns the HTMLTable.
Returns:
The table.

list

public java.lang.String list()
Returns a string containing the list of files and directories in the path defined in the HttpServletRequest.
Returns:
The list.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the PropertyChangeListener from the internal list. If the PropertyChangeListener is not on the list, nothing is done.
Parameters:
listener - The PropertyChangeListener.
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)

setHttpServletRequest

public void setHttpServletRequest(javax.servlet.http.HttpServletRequest request)
Sets the Http servlet request for the element.
Parameters:
request - The Http servlet request.

setOptions

public void setOptions(java.lang.String[] options)
Sets one or more optional html tags. The optional tags are placed after each file in the list. To perform an action on each specific file in the list with the optional html tags, two replacement sequences (%p and %f) must be specified in each options string. The %p sequence will be replaced with the path information for that file. The %f sequence will be replaced with the appropriate file name.

An Example:

// 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] = "Optional Action";

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

Parameters:
options - The optional html tags.

setSystem

public void setSystem(AS400 system)
Set the AS/400 system.
Parameters:
The - system.

setTable

public void setTable(HTMLTable table)
Set the HTMLTable to use when displaying the file list. This will replace the default HTMLTable used.
Parameters:
table - The HTML table.

sort

public void sort(boolean sort)
Sorts the list elements.
Parameters:
sort - true if the elements are sorted; false otherwise. The default is true.