W3C home > Mailing lists > Public > www-jigsaw@w3.org > November to December 1996

Re: re: modification to DirectoryResource.java

From: Anselm Baird_Smith <abaird@www43.inria.fr>
Date: Tue, 3 Dec 1996 10:41:06 +0100 (MET)
Message-Id: <199612030941.KAA08485@www43.inria.fr>
To: Alexandre Rafalovitch <alex@access.com.au>
Cc: www-jigsaw@w3.org
Alexandre Rafalovitch writes:
 > At 7:52 AM +1000 3/12/96, Jeff Sickel wrote:
 > >On Mon, 2 Dec 1996, Les Stockton wrote:
 > >>I read what Jeff Sickell did with DirectoryResource.java, and I like it.
 > >>I was wondering if an attribute should be added to DirectoryResource,
 > ...
 > Why do you want to change the original DirectoryResource? What stops you
 > from subclassing it (or copying) in a different class. Then you can modify
 > WWW template to use your directory resource instead of generic one. This
 > way, you can have your cake and eat it too. :-}
 > 
 > Another reason why it should be a different class is because there are many
 > possible representations for a directory content (tables, MCF, VRML, Java,
 > etc) and it would be nice to be able to handle them all, but that would be
 > a bloat on a class code and too many logic switches to care about every
 > time a request comes in. Making them different classes would let people
 > choose representations they want.

I would recommend doing the following (which I might do ;-) My
suggestion would be to have another attribute to the
DirectoryResource, say a "directory-lister" attribute, which gives the
class of the "lister" to use to emit directory listings.

But ! All this exists (I am just realizing it). Pretty easy in fact :-)
Write a new HTTPResource subclass, whose get method will look like:

[mail code quality, if more infos needed, let me know]
class FancyDirectoryLister extends HTTPResource {

   public void get(Request request) {
       // Get the parent directory to list:
       Resource r = getParent();
       if ( ! r instanceof ContainerResource )
           // Probably a config error, emit an errmsg
           getServer().errmsg(getClass().getName()+"@"+getURL()
                              + ": lister doesn't know about its parent");
       // Now, you have a pointer to the parent
       // As much fancy code as you want to do the directory listing
       
       return reply;
   }

}

Then add an instance of this resource to the DirectoryResource you
want to list. Name the resource "indexer" (for example), then as the
index attribute of the directory resource put "indexer". That's it !

Anselm.
BTW: There is a slight complication wrt the resource indexer, that's
for next mail ;-)
Received on Tuesday, 3 December 1996 04:41:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:25 GMT