Things the Framework Provides to an AJAX page

Visual LANSA Framework

Things the Framework Provides to an AJAX page

The Framework formally exposes various JavaScript objects for use by the AJAX page:

 

Name Type Comments

Using BUSY and SETBUSY

Function

Sets the Framework busy state to true or false

Using BUSY and SETBUSY

Function

Queries the current Framework state. Returns true or false

SENDREQUEST Function

Function

Sends a request to an AJAX function on the server

AVSAVEVALUE Function

Function

Saves a named value to the virtual clipboard

AVRESTOREAVALUE and AVRESTORENVALUE Functions

Function

Restores an alphanumeric named value from the virtual clipboard

AVRESTOREAVALUE and AVRESTORENVALUE Functions

Function

Restores a numeric named value from the virtual clipboard

Using STYLESHEET

Function

Returns the name of the variable style sheet that should be used for the user selected WINDOWS/XP/WEB look.

XP WEB look is no longer available.

Using AJAXGLOBAL to Share Information between Pages

Object

Global object for exchanging information between AJAX pages.

You can add tracing to your AJAX pages by using the supplied AVTRACE function.

Function

Add information to the trace record

 

 

 

 

 

 

Using BUSY and SETBUSY

BUSY

BUSY() returns True or False indicating whether the Framework is currently in a busy state.

Usually, but not always, you want to ignore a user’s request if the Framework is busy.

 

SETBUSY

SETBUSY(True or False) allows you to set the Framework’s busy state.

Usually, but not always, you want to use SETBUSY(True) just before sending a request to the server and then use SETBUSY(False) when the server operation completes.

 

Using SENDREQUEST

SENDREQUEST Function

Sends an asynchronous request to an AJAX function on the web server.

Syntax

SETBUSY(SenderWindow,Function,Request,Payload,ResponseHandler,UserObject,ReportErrors,RouteMessages)

 

Parameters

SenderWindow

Required. Always pass as window so as to identify the window from which the request originated.

Function

Required. The name of the AJAX style RDML or RDMLX function to be invoked on the server. If passed as null or "" it will default to the name of the function defined in the Framework along with this page.

Request

Required. The request that is to be passed into the AJAX function. Typically this value is used so that a single AJAX function can handle multiple different requests.

Payload

Required. The payload that is to be passed into the AJAX function. Typically used to qualify the Request with additional information. If passed as null or "" it will be passed into the AJAX function as blanks. Maximum length 256.  

ResponseHandler

Required. The JavaScript function that is to receive control when the AJAX function completes execution.

UserObject

Optional. Any JavaScript object that should be passed into the Handler. Typically used to qualify to the handler function the visual item it should update.   

ReportErrors

Optional. Indicates whether fatal errors detected in the AJAX function should be reported by the Framework. Passed as True or False. Default is True.

RouteMessages

Optional. Indicates whether messages returned by the AJAX function should be automatically routed into the Framework message area. Pass as True or False. Default is True.

 

Return Value

None.

 

Handle SENDREQUEST Responses

When you issue a SENDREQUEST operation you must nominate the JavaScript response handler function that is to receive control when the AJAX function completes execution:

SETBUSY(SenderWindow,Function,Request,Payload,ResponseHandler,UserObject,ReportErrors,RouteMessages)

  

The response handler JavaScript function must be declared like this:

function MyHandler(Function,Request,Payload,UserObject,FatalError,FatalMessage)

 

These parameters are always passed into the response handler by the Framework:

Function

The name of the AJAX function that has completed execution.

Request

The request that the AJAX function handled.

Payload

The payload that was presented to the AJAX function.

UserObject

The UserObject that was passed into the SENDREQUEST function that initiated this response.

FatalError

Contains True or False indicating whether a fatal error was detected when executing the AJAX function.

FatalMessage

A composite message containing all the error messages returned by an AJAX function that experienced a fatal error. If no fatal error was detected this value is passed as "".  

 

 

Using AVSAVEVALUE and AVRESTORExVALUE

These are like other virtual clipboard access routines used elsewhere in the Framework.

AVSAVEVALUE Function

Saves an alphanumeric or numeric value onto the Framework virtual clipboard.

 

Syntax

AVSAVEVALUE(vValue, sID1, sID2, sID3, iInstance, sLanguage)

 

Parameters

vValue

Required. Alphanumeric or numeric value to save to the virtual clipboard. 

If this parameter is a JavaScript variable of type string, the value is posed to the clipboard as an alphanumeric value and can therefore only be sensibly retrieved using the AVRESTOREAVALUE function (or equivalent). 

If it is of type number, it is posted as type numeric to the clipboard and can only be sensibly retrieved using the AVRESTORENVALUE function (or equivalent). 

 

sID1

Required. String that contains the Virtual Clipboard identifier 1.

sID2

Optional. String that contains the Virtual Clipboard identifier 2.

sID3

Optional. String that contains the Virtual Clipboard identifier 3.

iInstance

Optional. Integer that contains the instance number. Defaults to 1 when not specified. Instances are typically used to create lists of clipboard values and usually accompanied by another clipboard value that indicates how many entries currently exist in the list.

sLanguage

Optional. String that contains the language code. Defaults to ALL languages when not specified.

 

Return Value

None.

 

AVRESTOREAVALUE and AVRESTORENVALUE Functions

Restore an alphanumeric or numeric value from the Framework virtual clipboard.

 

Syntax

AVRESTOREAVALUE/AVRESTORENVALUE(Default, sID1, sID2, sID3, iInstance, sLanguage)

 

Parameters

Default

Required. String/Number that contains the default value to return if the value is not found. 

sID1

Required. String that contains the Virtual Clipboard identifier 1.

sID2

Optional. String that contains the Virtual Clipboard identifier 2.

sID3

Optional. String that contains the Virtual Clipboard identifier 3.

iInstance

Optional. Integer that contains the instance number. Defaults to 1 when not specified

sLanguage

Optional. String that contains the language code. Defaults to ALL languages when not specified.

 

Return Value

None.

 

Using STYLESHEET

STYLESHEET returns a script which contains the name of the main cascading style sheet associated with the current Framework web session.  

It has no arguments.

 

Using AJAXGLOBAL to Share Information between Pages

AJAXGLOBAL is a JavaScript object that is only accessible to AJAX pages.

You can use it to share information between AJAX pages.

 

For example, if AJAXPAGE01.HTM did this:

 

AJAXGLOBAL.CurrentCompany = “ACME Engineering” 

 

 

then AJAXPAGE002.HTM could do this:

   

alert(AJAXGLOBAL.CurrentCompany);  

 

 

Use code like:

 

if (typeof(AJAXGLOBAL.XXXXXX) == ”undefined”)  

 

 

to check whether object XXXXXX exists in AJAXGLOBAL. 

 

AJAXGLOBAL is a very efficient way to share information between AJAX pages, but it is only accessible to AJAX page scripts, so if you want share information with server AJAX functions or RAMP scripts you should use the virtual clipboard instead.

 

AJAXGLOBAL persists from session start to session end at which time it is destroyed.