Standard pattern for handling events in an HTML Widget, including returning HTML and processing actions.
Key Objects Used
ISKeyValueList
finScriptRequestInfo
Code
' HTML Widget event handler — called for each user interaction' eventId: "" for initial page load, or a custom event name' parametersJson: JSON parameters from the client-side JavaScript' returnValue: set this to return HTML content or JSON dataDim Parameters As ISKeyValueList = finBL.CreateKeyValueList()
Parameters.FromSimpleJsonString(parametersJson)
' Handle EventsSelect Case eventId
Case""' Initial page load — return the HTML template
returnValue = ScriptInfo.TemplateText
Case"GetData"' Custom event — return JSON dataDim result As String = ""
finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(myData, result)
returnValue = result
Case"Save"' Custom event — process a save actionDim name As String = Parameters.GetString("Name")
Dim value As Decimal = Parameters.GetDecimal("Value")
' ... process the save ...End Select