My First Web Application
In this tutorial we build a small web application for
registering publications and writing reviews about them.
This could be the start of a larger community site for sharing
bibliographic references and opinions about these. Such a site
could deal with the following entities: We start simply with the entity of publications. A first attempt
is the following 'record' data model of According to this Instead of using a The Entity associations provide a more informative type for a property
than the plain string type. While (string) value types are fine for
other properties such as title, abstract, and url, it would be useful
to have a better distinction in the role of these values. Therefore,
WebDSL provides a range of special value types such as Now we have a complete data model for publications and their
authors. From such a data model we can already generate a prototype
application for creating, viewing, and editing objects for the entity
types. An application definition starts with the keyword Here is the complete code of this
application. The code:Example Application: Keeping Track of Publications
Data Models: Records
Publication: entity Publication {
title :: String (name)
authors :: String
abstract :: String
published :: String
url :: String
}
entity definition, a Publication has
several String valued properties.
The properties of an entity type store the information
of entity objects of that type.
If e denotes an object of type Publication, then e.title
can be used to obtain the title of the the publication.
The title property has a name annotation, this has the
effect of adding a derived property name.
By convention, any WebDSL object can be asked for its name, which
provides a generic interface to naming an object, for instance
when producing links.Data Models: Associations
String to encode (the names of) the authors of a
Publication, we'd rather like to use a list of references to actual
Persons, i.e., objects represented by a proper entity definition in
WebDSL. To this end we introduce a Person entity and make the
authors property of Publication and association to a List of
Person. Likewise, we'd like to an association from Person to the
Set of Publications that the Person has authored. Moreover,
we'd like this relation to be consistent. That is, whenever, a
person is listed as author of a publication, the publication should
be in the set of publications of that person. This is what the
inverse annotation on the authors property achieves. entity Publication {
title :: String (name)
authors -> List<Person> (inverse=Person.publications)
abstract :: String
published :: String
url :: String
}
entity Person {
fullname :: String (name)
homepage :: String
email :: String
address <> Address
publications -> Set<Publication>
}
entity Address {
street :: String
city :: String
country :: String
phone :: String
}
authors association is a reference association. In contrast,
the address association of Person is a composite association,
which indicates that the address is 'owned' by the person; if the
person object is deleted, the corresponding address object can be
deleted as well.Data Models: Special Types
Text,
WikiText Date, URL, and Email that convey the sort of string
value that is contained in the property, such that appropriate
operations and user interfaces can be attached to these properties. entity Publication {
title :: String (name)
authors -> List<Person> (inverse=Person.publications)
abstract :: Text
published :: Date
url :: URL
}
entity Person {
fullname :: String (name)
homepage :: URL (optional)
email :: Email (optional)
address <> Address
publications -> Set<Publication>
}
entity Address {
street :: String
city :: String
country :: String
phone :: String
}
Defining an Application (Mark 1)
application
and then contains a number of descriptions and sections containing
entity and other definitions. application org.researchr.www
description { A community site about research. }
section data model
entity Publication { ... }
entity Person { ... }
entity Address { ... }
section templates
define main() { body() manageMenu() }
define body() {}
define manageMenu() {}
define page home() { main() }
Contributions by EelcoVisser