[Seaside] How to approach building a Deltawerken application, Part 1

Stephan Eggermont stephan at stack.nl
Fri Sep 14 10:59:46 UTC 2012

Class categories

When building a Deltawerken application called AppName, create the following 
class categories:


Put the domain classes in AppName-Model
Drive the development of the domain classes from tests in AppName-Model-Tests
Put the Seaside related code in AppName-Web
The Announcements for navigating the site go in AppName-Announcements

Once either of those categories gets too large (when you need to scroll the list
of classes in the category), create a fitting new category and distribute the classes.
Now Beach-Parasol allows web testing with Selenium Webdriver, you probably
also want to create AppName-Web-Tests (http://ss3.gemstone.com/ss/Parasol.html)

Accessing the model

To access the model from the web, you either give (at least) one of the domain classes
a class (instance) var or add a separate model class. 

In Storyboard, SBUser has a class instance variable users. The class method users
returns these users, and when nil creates a collection of users with a default administrator.
During development, the class method resetUsers allows cleaning up.

The alternative would be to add a class SBModel with a class variable default.
	^default ifNil: [default := self new]

  default := nil

Then add accessors for the entry points 
	users ifNil: [users := OrderedCollection new.
		self addDefaultUsers].

Describing the model classes

To create editing or reporting forms, describe the model classes
and create an accessor returning an array of methodSymbols

	^#( storyNameField #descriptionField typeField sizeField stateField historyField) 

At the class side, create a xxxField method for all needed fields.

SBStory has a storyName instance variable. The storyName is 
a required string.

	^DEStringField new
		label: 'Name';
		accessor: #( #storyName );
		validator: (DEStringValidator new
			required: true;
			errorMessage: 'Name is required'

SBMember has a user instance variable. In a report, its email is needed

	^SBUser emailField
		addToAccessor: #( #user );

Creating the application

Add a subclass of WAFileLibrary to AppName-Web. Put the css in mainCss,

	^#( mainCss )

Create a application entrypoint. In StoryBoard this is SBMain, a subclass of
WAComponent. It renders its children

	^Array with: self loginForm with: self mainForm

Easiest is to create a copy, change class side description and initialize
Don't forget to add your filelibrary. The sessionClass is often not needed.
Change instance side title and the createLogin and createMainForm methods.

The createMainForm creates a DEPageChoice component. It needs to interact 
with the loginForm. When the register button is pressed, the loginForm sends 
the SBRegisterUser announcement. The addPage:announcement: makes sure 
that the page is shown when receiving the announcement. Deltawerken has 
default announcements for logging on and off 

More information about the seaside mailing list