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

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

Embed Size (px)

Citation preview

Page 1: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2000

Building Web Applications With Building Web Applications With WebjectsWebjects

Michael D. Barker

The MIT Educational Media Creation Center

September 2001

Page 2: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

What's a Webject?What's a Webject? 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.

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

Webject as a one set of data.

Page 3: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© 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 4: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

ListerLister

HTML Form

Lister ServletWebject

List

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

HTMX Form

Page 5: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

DisplayerDisplayer

HTML Form

Displayer ServletWebject

List

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

HTMX Form

Page 6: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© 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. Often, the web form is generated by displayer.

Page 7: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© 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.

Page 8: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Typical ApplicationTypical Application

Collect information (using Capture) Display a list of results (using Lister) With edit buttons (using Displayer) that

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

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

Page 9: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

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

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

file page templates (htmx files)

Page 10: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Webject Specification FileWebject Specification 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 11: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Possible AttributesPossible Attributes

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

submit) multiple="1" May have multiple values default="value" equals="name" use value of name defaultequals="name" use value of name as default

Page 12: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Webject List FileWebject List 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 13: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

HTMX FileHTMX File

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

non-blank value <WEBJECTDATASELECT name=value> :

SELECTED if value(Lister only) <WEBJECTLIST count>: number of items in list <FRAGREPEAT WEBJECT>...</WEBJECT>: repeat

for all elements in list

Page 14: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

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

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

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

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

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

Page 15: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

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

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

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

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

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

the code for details (list follows)

Page 16: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

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

Page 17: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

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

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

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

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

(where are the templates)

Page 18: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Lister ParametersLister ParametersOptional servlet. SomeName.initArgs=listtemplate=<filename>Defaults to listtemplate.htmx servlet. SomeName.initArgs=mimetype=<mime-type>Defaults to text/html servlet. SomeName.initArgs=sortby=<date|title>Defaults to date 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 19: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Displayer ParametersDisplayer Parameters

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

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

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

list) servlet.SoName.initArgs=templatedir=<filename>

Page 20: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Displayer ParametersDisplayer ParametersOptional servlet.SoName.initArgs=webjecttemplate=<filename>

Defaults to webjecttemplate.htmx servlet.SoName.initArgs=notfoundtemplate=<filename>

Defaults to notfoundtemplate.htmx servlet.SoName.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) and

username (a username parameter will be supplied)

Page 21: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Revise ParametersRevise Parameters

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

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

Page 22: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Revise ParametersRevise Parameters

Optional servlet. SoName.initArgs=successtemplate=<filename>

Defaults to revisesucess.htmx servlet. SoName.initArgs=errortemplate=<filename>

Defaults to reviseerror.htmx

Page 23: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Deleter ParametersDeleter Parameters

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

Runtime SomeName?ID=xxxxx

Or

SomeName?id=xxxxxx

Page 24: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Deleter ParametersDeleter Parameters

Optional servlet. SoName.initArgs=deletedtemplate=<filename>

Defaults to deletedtemplate.htmx

Page 25: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

Likely Future Additions to the Likely Future Additions to the Webject LibraryWebject Library

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

Conversion to use mySQL, Oracle, or other database

Page 26: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

For Additional InformationFor Additional Information

<https://web.mit.edu/emcc/Private/library/webjects.html>

Brian Bermack's original documentation

Page 27: © MIT 2000 Building Web Applications With Webjects Michael D. Barker The MIT Educational Media Creation Center September 2001

© MIT 2001

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

Michael Barker– [email protected]

– 617/253-0119

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