Previous Topic: Example: Text Input Box as an HTML ComponentNext Topic: Edit an Automated Task


Example: End-User Input Handling

After the user interface page displays, in many cases it is necessary to handle end-user input when the user clicks one of the footer buttons, such as Next, Previous, or Finish. You implement handler functions to handle end-user input. You implement a function named NextButtonHandler to handle the clicking of the Next button. You can use the PreviousButtonHandler and FinishButtonHandler functions to handle the Previous and Finish buttons.

The handler performs the following actions:

Example: End-User Input Handling

HTML components that wrap input controls, such as the InputBox component, expose methods to access the values supplied by the end user. In this case, the GeUserInput() function is exposed.

You can control the next step that the framework presents as follows:

You can handle the Next button being clicked by supplying a NextButtonHandler. Because the NextButtonHandler has to access the HTML component that was created in the OnLoad, the declaration (Dim statement) of this variable is placed outside these functions. Thus, the entire step code would look as follows:

Dim myInputBox

Function OnLoad
	Set myInputBox = UI.MakeInputBox()
	myInputBox.PromptText = "Please enter your name:"
	Step.Controls.Add(myInputBox)
End Function
Function NextButtonHandler
	Dim userInputValue

	' Retrieve the data supplied by the user
userInputValue = myInputBox.GetUserInput()

' Validate the data
If Len(userInputValue) = 0 Then
	' Show error message
	Functions.ShowMessage "You must supply a name"

	' Re-present current step
	NextButtonHandler=False 
Else
	' Log the data
	Functions.LogMessage "User name set to: " & userInputValue

	' Store the data
	Task.SetNamedDataItem "UserName", userInputValue

' Proceed to next step 
NextButtonHandler=True  
End If
End Function