Building Web Applications With Webjects

37
© MIT 2000 Building Web Applications With Building Web Applications With Webjects Webjects Michael D. Barker The MIT Educational Media Creation Center November 2001

Transcript of Building Web Applications With Webjects

Page 1: Building Web Applications With Webjects

© MIT 2000

Building Web Applications With Building Web Applications With WebjectsWebjects

Michael D. BarkerThe MIT Educational Media Creation

Center

November 2001

Page 2: Building Web Applications With Webjects

© MIT 2001

Key Parts of This PresentationKey Parts of This Presentation

n What's a Webject?n Graphic Views of the Servletsn Configuration Filesn Parameters

Page 3: Building Web Applications With Webjects

© MIT 2001

What's a What's a WebjectWebject??n Webject as one set of data (and a webjectlist as

a collection of webjects!)n A set of servlets, allowing handling of several

"standard" operations on data over the web by setting up the correct forms and configuration files. Notice that I did not say writing code –the servlets are deliberately designed to be generic, so that changes are made in the forms and configuration files, not the code.

n At this point in time, there are six webject servlets: Capture, Lister, Displayer, Revise, Deleter, and Publisher.

Page 4: Building Web Applications With Webjects

© MIT 2001

Key Parts of This PresentationKey Parts of This Presentation

n What's a Webject?n Graphic Views of the Servletsn Configuration Filesn Parameters

Page 5: Building Web Applications With Webjects

© MIT 2001

CaptureCapture

HTML Form

Capture Servlet Webject

List

Capture is used to collect information from a web form for ONE webject. Often, the web form is just a simple html page, with form action posting to capture.

Page 6: Building Web Applications With Webjects

© MIT 2001

ListerLister

HTML Form

Lister ServletWebject

List

Lister generates a web form displaying information from all the webjects in a list.

HTMX Template

Page 7: Building Web Applications With Webjects

© MIT 2001

DisplayerDisplayer

HTML Form

Displayer ServletWebject

List

Displayer generates a web form displaying information from a single webject.

HTMX Template

Page 8: Building Web Applications With Webjects

© MIT 2001

ReviseRevise

HTML Form

Revise Servlet Webject

List

Revise is used to collect information from a web form to make changes for ONE webject. Almost always the web form is generated by displayer.

Page 9: Building Web Applications With Webjects

© MIT 2001

DeleterDeleter

HTML Form

Deleter Servlet Webject

List

Deleter is used to remove one webject from the list. Often, it is invoked from a form generated by lister, although it is often useful to use displayer to generate a form showing the details of the webject being deleted to confirm that the correct object has been selected. (There is no undelete!)

Page 10: Building Web Applications With Webjects

© MIT 2001

PublisherPublisher

HTMLFile

Publisher ServletWebject

List

Publisher generates a file containing a web form displaying information from all the webjects in a list.

HTMX Template

Page 11: Building Web Applications With Webjects

© MIT 2001

Typical ApplicationTypical Application

(with apologies for torturing English)n Collect information (using Capture)n Display a list of results (using Lister)n With edit buttons (using Displayer) that

bring up forms whose submit changes the information (using Revise)

n And delete buttons (that bring up a form to confirm, then invoke Deleter)

Page 12: Building Web Applications With Webjects

© MIT 2001

Key Parts of This PresentationKey Parts of This Presentation

n What's a Webject?n Graphic Views of the Servletsn Configuration Filesn Parameters

Page 13: Building Web Applications With Webjects

© MIT 2001

Parameters, XML files, and Parameters, XML files, and suchsuch

n Every servlet has some parameters.n webject specification file n webject list file n Configuration in servlet zone properties

file (this will change with Tomcat!)n page templates (htmx templates)

Page 14: Building Web Applications With Webjects

© MIT 2001

Webject Webject Specification FileSpecification File<?xml version="1.0" encoding="UTF-8"?><defnspec docclass="edu.mit.emcc.webject.XMLObjectSpecFile" >

<parameter name="term" required="1" errorRequired="You must provide a term to be defined."

/>

<parameter name="definition" required="1"errorRequired="You must provide a definition for the term."

/>

<parameter name="SUBMIT" ignored="1"/><parameter name="Submit" ignored="1"/>

</defnspec>

Replace the parameter definitions with your data fields.

Page 15: Building Web Applications With Webjects

© MIT 2001

Possible AttributesPossible AttributesAmong the attributes that can be specified for a parameter are: n name="name" The name of the parameter. Required.n required="1" n errorRequired="message"n optional="1" (default)n ignored="1" (discard even if value present – good for discarding

submit)n multiple="1" May have multiple valuesn default="value"n equals="name" use value of namen defaultequals="name" use value of name as defaultn format="type" where type is one of name, extphone, phone, email,

state, zipcode, password

Page 16: Building Web Applications With Webjects

© MIT 2001

Webject Webject List FileList File

<?xml version="1.0" encoding="UTF-8"?><iplist type="iprange"specfile="../conf/iplistspec.xml" docclass="edu.mit.emcc.webject.WebjectList" webjectclass="edu.mit.emcc.webject.Webject"> <lastid>1</lastid></iplist>

Page 17: Building Web Applications With Webjects

© MIT 2001

Webject Webject List With Files FileList With Files File<?xml version="1.0" encoding="UTF-8"?><iplist type="iprange"specfile="../conf/iplistspec.xml" docclass="edu.mit.emcc.webject.WebjectList" webjectclass="edu.mit.emcc.webject.Webject"filestoredir="directory" (relative to the webject

file itself)filedirmaxsize="bytecount"fileurlprefix="url/prefix" > <lastid>1</lastid></iplist>

Page 18: Building Web Applications With Webjects

© MIT 2001

HTMX TemplatesHTMX Templatesn Normal HTML plus(Displayer and Lister)n <WEBJECTDATA name> : the value of name n <WEBJECTDATACHECK name>: CHECKED if

non-blank value n <WEBJECTDATASELECT name=value> :

SELECTED if valuen <WEBJECTDATAHTML name>: value escaped for

use in html form (e.g. " becomes &quot;)(Lister only)n <WEBJECTLIST count>: number of items in listn <FRAGREPEAT WEBJECT>...</fragrepeat>: repeat

for all elements in list

Page 19: Building Web Applications With Webjects

© MIT 2001

HTMX TemplatesHTMX Templates

n <WEBJECTFILETYPE name> content-type of file

n <WEBJECTFILEURL name> URL for the file

n <WEBJECTFILETIMESTAMP name> last update time

Page 20: Building Web Applications With Webjects

© MIT 2001

Key Parts of This PresentationKey Parts of This Presentation

n What's a Webject?n Graphic Views of the Servletsn Configuration Filesn Parameters

Page 21: Building Web Applications With Webjects

© MIT 2001

Capture ParametersCapture ParametersMinimum:n servlet.AddTicket.code=edu.mit.emcc.webject.Capture

(alias)n servlet.AddTicket.initArgs=root=/development (root

directory to prepend to all other file names)n servlet.AddTicket.initArgs=capturepage=ListTickets or

servlet.Register.initArgs=capturepage=../lobby/register.html (html form, allows gets to servlet to redirect to form)

n servlet.AddTicket.initArgs=webjectlist=data/ccoach/accessinfo/tickets.xml (the webject list)

Page 22: Building Web Applications With Webjects

© MIT 2001

Capture ParametersCapture ParametersAdditional:n servlet. SomeName.initArgs=templatedir=<filename>

Directory where HTML templates are storedn servlet. SomeName.initArgs=successtemplate=<filename>

for successful submissions (default: capturesuccess.htmx)n servlet. SomeName.initArgs=errortemplate=<filename>

for validation errors (captureerror.htmx)n servlet.SomeName.initArgs=duplicatetemplate=<filename

> for duplicate keys (captureduplicate.htmx)n There is also a set of parameters to generate email – read

the code for details (list follows)

Page 23: Building Web Applications With Webjects

© MIT 2001

Capture Parameters (email)Capture Parameters (email)n servlet.SomeName.initArgs=mailserver=(address)n servlet.SomeName.initArgs=partialemailtemplate=(filename) n servlet.SomeName.initArgs=partialto=(address)n servlet.SomeName.initArgs=partialsubject=(subject)n servlet.SomeName.initArgs=partialfrom=(address)n servlet.SomeName.initArgs=completeemailtemplate=(filename) n servlet.SomeName.initArgs=completeto=(address)n servlet.SomeName.initArgs=completesubject=(subject)n servlet.SomeName.initArgs=completefrom=(address)

Page 24: Building Web Applications With Webjects

© MIT 2001

Capture Parameters (file Capture Parameters (file upload)upload)

n servlet.SomeName.initArgs=filetempdir=(directory)n servlet.SomeName.initArgs=filemaxpostsize=(int)Note: must be coordinated with change in webject list

file (see Webject List with Files)

Page 25: Building Web Applications With Webjects

© MIT 2001

Lister ParametersLister ParametersMinimaln servlet.SomeName.code=edu.mit.emcc.webject.Lister

(alias)n servlet. SomeName.initArgs=projectroot=<directory>

(root of files)n servlet. SomeName.initArgs=webjectlist=<filename>

(data list)n servlet. SomeName.initArgs=templatedir=<filename>

(where are the templates)

Page 26: Building Web Applications With Webjects

© MIT 2001

Lister ParametersLister ParametersOptionaln servlet. SomeName.initArgs=listtemplate=<filename>Defaults to listtemplate.htmxn servlet. SomeName.initArgs=mimetype=<mime-type>Defaults to text/htmln servlet. SomeName.initArgs=sortby=<fieldname>n servlet. SomeName.initArgs=sortmethod=<text|date>Defaults to textn servlet. SomeName.initArgs=daysback=<number>How many days back to include (defaults to all) Often

entered in url (servlet name?daysback=5 for example)

Page 27: Building Web Applications With Webjects

© MIT 2001

Lister Request ParametersLister Request Parametersn daysback=nn sortby=fieldnamen sortmethod=text|daten selectby=fieldnamen selectvalue=value

Page 28: Building Web Applications With Webjects

© MIT 2001

Publisher ParametersPublisher Parametersn All the Lister parameters plus:n servlet.Publisher.initArgs=success=[filename]

(relative to templatedir)n servlet.Publisher.initArgs=failure=[filename]

(relative to templatedir)n servlet.Publisher.initArgs=outfile=[filename]

(relative to projectroot)

Page 29: Building Web Applications With Webjects

© MIT 2001

Displayer ParametersDisplayer Parameters

Minimaln servlet.SomeName.code=edu.mit.emcc.webject.Displayer

(alias)n servlet.SomeName.initArgs=projectroot=<directory> (root

for files)n servlet.SomeName.initArgs=webjectlist=<filename> (data

list)n servlet.SomeName.initArgs=templatedir=<filename>

Page 30: Building Web Applications With Webjects

© MIT 2001

Displayer ParametersDisplayer ParametersOptionaln servlet.SomeName.initArgs=webjecttemplate=<filename>Defaults to webjecttemplate.htmxn servlet.SomeName.initArgs=notfoundtemplate=<filename>Defaults to notfoundtemplate.htmxn servlet.SomeName.initArgs=idsource=<param|auth|username>How to get id of webject. Defaults to parameter (ID=xxx).Also accepts auth (look up user in webject list) andusername (a username parameter will be supplied)

Page 31: Building Web Applications With Webjects

© MIT 2001

Revise ParametersRevise Parameters

Minimaln servlet.SomeName.code=edu.mit.emcc.webject.Revise

(alias)n servlet.SomeName.initArgs=projectroot=<directory>n servlet.SomeName.initArgs=editpage=<URL>n servlet.SomeName.initArgs=webjectlist=<filename>n servlet.SomeName.initArgs=templatedir=<filename>

Page 32: Building Web Applications With Webjects

© MIT 2001

Revise ParametersRevise Parameters

Optionaln servlet.SomeName.initArgs=successtemplate=<filename>Defaults to revisesucess.htmxn servlet.SomeName.initArgs=errortemplate=<filename>Defaults to reviseerror.htmx

Page 33: Building Web Applications With Webjects

© MIT 2001

DeleterDeleter ParametersParameters

Minimaln servlet.SomeName.code=edu.mit.emcc.webject.Deleter (alias)n servlet.SomeName.initArgs=projectroot=<directory>n servlet.SomeName.initArgs=webjectlist=<filename>n servlet.SomeName.initArgs=templatedir=<filename>

Runtimen SomeName?ID=xxxxx

OrSomeName?id=xxxxxx

Page 34: Building Web Applications With Webjects

© MIT 2001

DeleterDeleter ParametersParameters

Optionaln servlet.SomeName.initArgs=deletedtemplate=<filename>Defaults to deletedtemplate.htmx

Page 35: Building Web Applications With Webjects

© MIT 2001

Likely Future Additions to the Likely Future Additions to the Webject Webject LibraryLibrary

n "archive" – put a class of webjects into another file and remove from the "active" file

n Conversion to use mySQL, Oracle, or other database

n Multi-valued field displayn Faster listern Basic webject build tool

Page 36: Building Web Applications With Webjects

© MIT 2001

For Additional InformationFor Additional Information

n <https://web.mit.edu/emcc/Private/library/webjects.html> Brian Bermack's original documentation

Page 37: Building Web Applications With Webjects

© MIT 2001

You Can Reach Us...You Can Reach Us...

n Michael Barker– [email protected]– 617/253-0119

nEMCC website: http://web.mit.edu/emcc/