Information Flow Between AJAX Pages and Functions

Visual LANSA Framework

Information Flow Between AJAX Pages and Functions

The primary means of sharing information between AJAX pages, AJAX functions and RAMP scripts is the virtual clipboard.

 

The virtual clipboard is essentially a namespace of names, values and lists:

  • JavaScript code (executing on the client PC) in your AJAX pages can read or write information from/to the virtual clipboard.  
  • RDML/RDMLX code (executing on the web server) in your AJAX functions can read or write information from/to the virtual clipboard.
  • RAMP JavaScript code (executing on the client PC) in your AJAX pages can read or write information from/to the virtual clipboard.

 

The clipboard they all use is shared. It is created when the Framework-WEB session is started and persists until the session ends, when it is destroyed. Clipboard content changes are invisibly transferred between the client PC and web server (or vice-versa) as required.

Only the clipboard changes are transferred, but of course the number of changes you make impacts how much information needs to be transferred.

Some good practice tips for using the virtual clipboard are:  

  • You should develop and document standards for the names and values it contains.
  • The amount of clipboard data you transfer from the client to the server particularly impacts application performance. Transferring large amounts of data from the server to the client has less impact. 

 

AJAX Information in the Framework Virtual Clipboard

When you are using AJAX applications, the Framework puts some information onto the virtual clipboard automatically. Generally you should treat this information as read-only so as to avoid interfering with the operation of the Framework.

 

Name Part 1 Name Part 2 Name Part 3 Usage Comment

AJAX

SYSTEM

AJAXPAGE

Current AJAX page name

AJAX

SYSTEM

AJAXMODULE

Default RDML or RDML AJAX function name

AJAX

SYSTEM

REQUEST

Current request

AJAX

SYSTEM

PAYLOAD

Current payload

AJAX

SYSTEM

RETURNCODE

Latest Return Code

AJAX

SYSTEM

MESSAGECOUNT

Latest Message Count (can be updated)

AJAX

SYSTEM

MESSAGE

Latest Message Instance

AJAX

SYSTEM

<any other>

Do not use this namespace. It is reserved for the current and future Framework versions.

 

Typically you will only ever need to access AJAX.SYSTEM.REQUEST and AJAX.SYSTEM.PAYLOAD in your server side AJAX functions like this:

 

 

* Get the action and payload that the Javascript sent .... 

 

Execute Subroutine(GETA) With_Parms(SYSTEM REQUEST 1 #REQUEST) 

Execute Subroutine(GETA) With_Parms(SYSTEM PAYLOAD 1 #PAYLOAD) 

 

* Now switch on the requested action 

 

Case Of_Field(#REQUEST) 

 

* Load 10 sample entries 

 

When Value_Is(= LOAD10) 

Execute Subroutine(Load10) 

 

* Validate a zip code 

 

When Value_Is(= VALIDATE) 

Execute Subroutine(VALIDATE) 

 

* Handle a bad request 

 

Otherwise 

Abort Msgid(DCM9899) Msgf(DC@M01) Msgdta(('Unknown request ' + #REQUEST + ' received by ' + *FUNCTION)) 

 

Endcase 

 

Typically this allows one AJAX function to handle many different AJAX page requests coming from many different AJAX pages.