Session ModeThe Ses Library implements part of the session mode described in the Sessions section of the Language Reference. You need to insert
< include name="ses.hei" />
into the beginning of your page to use the following functions.
< inherit Interactive >
Interactive is an abstract class. Objects that want to provide interactive functionality are supposed to inherit this class. It is not possible to directly create interactive objects.
An interactive object must display some kind of interactive user interface element on the browser screen, such as a link, a form field, a form button, etc. Once the user submits this element, i.e. clicks on a link or button or submits a form, the process method of the interactive object is called. You can then program a process method, that reacts to the users action in an appropriate way. Interactive objects sustain their data between at least two page requests. So the complete object data is available for the process method.
The following needs to be done to make all of this work smoothly. An object inherits the method registerme from the interactive class. registerme must be called somewhere within the constructor that is displaying the object on the browser screen. registerme assigns a browser object id (bid) to the object and stores it as this._bid. The interactive HTML user interface element must have a control name that starts with the value of this._bid followed by a period. Finally a process method needs to be programmed.
<[let this.] registerme >
Registerme is a method of the Inherited class that is passed on to an interactive object. Registerme must be called to actually make an interactive object listen to user input. As a side effect, registerme assigns a bid to the object and stores it in this._bid.
<let this. process ( param )>
Interactive objects inherit an empty process method that is intended to be overwritten. It should react to the user input in an adequate way. As parameters process receives the user input, i.e. all form fields that start with the objects bid. Additionally, all the object's data can be accessed in this way.
Process can basically contain any heitml statements. However note that the text output of process is ignored and not displayed, unless the debugdisplay component is used to display it as test output. Typically process routines will modify the database or memory data structures that are displayed later. In the case of a persistent object, it can be useful to just change the object's own data. It is also possible to call methods of other components or to send them messages using <sessionSendMsg>. Additionally <sessionRedirect> can be called to redirect to another page.
<let error= check ( param )>
Interactive objects inherit an empty check method, that might be overwritten. The check method is called before the process method and receives the same parameters. It must check if the process method will work out. If so, check must return null, otherwise a value other than null.
It is possible that multiple interactive objects receive user input. In this case heitml performs a two phase processing. This is to avoid the processing of some objects, while others are showing an error message. If any object delivers an error, then no processing (e.g. a database) change should occur. The Ses Library therefore first calls the check methods of all objects that received user input. Only if there was no error all the process methods are called.
ActionsThe following routines are supposed to be called by process or check routines.
< sessionRedirect location />
Requests a redirection to a new location. The redirection is performed only if all components are processed successfully.
< sessionSendMsg receiver msgkind k />
Sends a message to a component named receiver. msgkind must be the message kind and k a tuple of parameters, such as the key of a database record for a database form.
The receiver can be located either on the same page or on another Web page when used together with <sessionRedirect>.
© 1996-2022 H.E.I. All Rights Reserved.