Main.html
<HTML>
<HEAD> <TITLE>Visitors</TITLE> </HEAD>
<BODY>
<H1>Visitors</H1>
<HR>
To record your visit, please enter your name below.
<WEBOBJECT NAME="FORM">
<WEBOBJECT NAME = "NAME_FIELD"></WEBOBJECT>
<P>
<WEBOBJECT NAME = "SUBMIT_BUTTON"></WEBOBJECT><P>
</WEBOBJECT>
<HR>
<P>
Number of visitors to this page:
<WEBOBJECT NAME = "VISITORS_NUM"></WEBOBJECT>
<P>
Most recent visitor:
<WEBOBJECT NAME = "LAST_VISITOR"></WEBOBJECT>
</BODY>
</HTML>
Main.wos
id number, aName;
- awake {
if (!number) {
number = [WOApp visitorNum];
number++;
[WOApp setVisitorNum:number];
}
return self;
}
- recordMe
{
if ([aName length]) {
[WOApp setLastVisitor:aName];
[self setAName:@""]; // clear the text field
}
}
Main.wod
FORM: WOForm {method="POST";};
NAME_FIELD:WOTextField {
value = aName;
};
LAST_VISITOR:WOString {
value = WOApp.lastVisitor;
};
VISITORS_NUM:WOString {
value = WOApp.visitorNum;
};
SUBMIT_BUTTON:WOSubmitButton {
action = recordMe;
};
Application.wos
id lastVisitor; // the most recent visitor
id visitorNum; // the total number of visitors the page
- awake
{
// Obsolete sessions that have been inactive for more than 2 minutes
[WOApp setSessionTimeOut:120];
visitorNum = 0;
}