Websydian v6.1 online documentationOnline documentation - Websydian v6.1

Implementing the SessionWithLayoutControl Pattern

Inherit from the SessionWithLayoutControl pattern

To implement Layout Control, the implemented Session Management pattern must inherit from SessionWithLayoutControl:

MySession is a ENT SessionWithLayoutControl

The specification above, will include a TemplateCode field on the Session entity which will be accessed by the abstract Page Generator function when reading the associated Document Template.

Set Template Code

Before the first Page is generated in a user session, the Template Code needs to be set (the Template Code may be changed later on as a result of a user action).  This is done by casting a value to the Session<TemplateCode> field in the 0 Before calling session creation edit point of the CallFirstPageGenerator function.

If Layout Control is used with the Message Store pattern and a value for the Language Code is already specified in the CallFirstPageGenerator function, this value may be used for the Template Code as well.

Hint: A Websydian application may want to use the default language of the browser, which can be retrieved as a Web server variable.  This is done by calling the ServiceFunctions.GetEnvironmentVariable function with the Browser language value as input, and then extract the first two characters from the output.

Generate and Build Objects

The Session entity has been modified, so all objects scoped under the implemented Data.Session entity need to be re-generated and built.

In addition, all Page Generators having the Abstract.PageGenerator function of the Implemented Session pattern in their inheritance path must be generated and built.  These Page Generators will now all support Layout Control.

Create Template Folders

Currently, all Document Templates are stored in a separate HTML folder on the Web server.  Scoped under that folder, a sub-folder for each Template set should be created.  By specifying names for these sub-folders corresponding to the possible literal values of the Template Code field, the Document Template will automatically be picked from the folder specified by the Template Code on the Session table.

Specify Template Sets

The last thing to do is to specify the different sets of Document Templates and save these in each their Template folders.