W3C home > Mailing lists > Public > www-jigsaw@w3.org > May to June 1996

form resource brief overview

From: Anselm Baird-Smith <abaird@w3.org>
Date: Fri, 21 Jun 1996 18:00:04 +0500
Message-Id: <9606212200.AA05738@www18.w3.org>
To: alex@access.com.au (Alexandre Rafalovitch)
Cc: www-jigsaw@w3.org

Here is a brief overview of how to use the w3c.jigsaw.forms high level
package. I won't discuss the w3c.jigsaw.forms.PostableResource wich is
pretty simple to use, but rather the high level stuff.

Basically this hight level form interface provides three abstractions,
two o f them are related to presentation, the last one is related to
semantics:

a) w3c.jigsaw.forms.FormResource
    The basic form class.
b) w3c.jigsaw.forms.FormCardResource
    Form cards - a form can support multiple cards 
c) w3c.jigsaw.forms.FormCardHandler
    The piece of code that implements the semantics of your code.


Building the presentation:

The presentation of a form is managed by a central FormResource
instance. The instance is created through the normal Jigsaw resource
editor (by AddResource in some DirectoryResource). You will usually
want to overide the default initialize method to do some init (such as
creating form cards). A typical initialize method of a sub-class of
FormResource will look like:

public void initialize(Object values[]) {
    super.initialize(values) ;
    // Create a form card handler:
    handler = new MyFormCardHandler();    // we'll come back to this
    card1 = defineCard(handler, "CardOne", "Header of CardOne");
    card2 = defineCard(handler, "CardTwo", "Header of CardTwo");
}

Before going back to the handler, let's have a look at actually
filling the cards with fields to edit. The forms package comes with a
number of predefined field types (field to edit values of a given
types). Let's say we want to edit an integer in CardOne and a Date in
CardTwo:

    // Create an integer field to edit some age value
    FormFieldInterface field = new IntegerField("integer" // name
                                               , "age"    // title
                                               , null     // Help URL if any
                                               , new Integer(2)); // default
    // Add the field to card1
    card1.addField(field)
    // Create a date field
    field = new DateField("date", "birthdate", null, new Long(0));
    card2.addField(field);

This defines the presentation of the form, now back to the semantics,
we have to define our own card handler class:

class MyFormCardHandler implements FormCardHandler {

    // Check the methods of this class, and override the one you want
}

[I am just realizing that the interface is broken ! The
notifyEndProcessing method should be able to return a reply insteead
of just a relocation, I'll fix this]

Anyway, I hope this will help you start at least, let me know if you
are stuck.

Anselm.


                                                 
    
                                                 
    
                                                 
    
Received on Friday, 21 June 1996 18:00:20 GMT

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