WebForm
The WebForm class contains functions and properties allowing to handle your Qodly web page components. 4D.WebForm objects are instantiated with the webForm command.
History
| Release | Changes |
|---|---|
| 20 R6 | Added enableState() and disableState() |
| 20 R2 | Added |
Commands and functions
objects that are available directly as properties |
| .disableState( state : string) disables the rendering of the state in the current web page |
| .enableState( state : string ) enables the rendering of the state in the current web page |
| .setError( msg : string) sends msg as an error message to the web page |
| .setMessage( msg : string) sends msg as an information message to the web page |
| .setWarning( msg : string) sends msg as a warning message to the web page |
.componentName
.componentName : 4D.WebFormItem
Description
The components of web pages are objects that are available directly as properties of these web pages.
The returned objects are of the 4D.WebFormItem class. These objects have functions that you can use to manage your components dynamically.
Example
shared singleton Class constructor()
var myForm : 4D.WebForm
var component : 4D.WebFormItem
myForm:=webForm //returns the web page as an object, each property is a component
component:=myForm.myImage //returns the myImage component of the web page
While myForm may not display typical object properties when examined in the debugger, it behaves as if it were the actual webForm object. You can interact with the underlying webForm object's properties and functions through myForm. For example, you can dynamically manipulate page components or transmit messages to web pages using specialized functions like myForm.setMessage().
.disableState()
.disableState( state : string)
| Parameter | Type | Description | |
|---|---|---|---|
| state | string | -> | Name of state to disable from the web page |
Description
The .disableState() function disables the rendering of the state in the current web page.
This function does nothing if:
- the state is currently not enabled in the web page,
- the state does not exist for the web page.
If you enable or disable several states in the same user function, all modifications are sent at the same time to the client once the function ends.
For more information on web pages states, please refer to the States section in the Qodly documentation.
.enableState()
.enableState( state : string )
| Parameter | Type | Description | |
|---|---|---|---|
| state | string | -> | Name of state to enable on the web pages |
Description
The .enableState() function enables the rendering of the state in the current web page.
This function does nothing if:
- the state has already been enabled on the web page,
- the state does not exist for the web page.
If you enable or disable several states within the same user function, all modifications are sent at the same time to the client once the function ends.
For more information on web page states, please refer to the States section in the Qodly documentation.
Example
You enable a specific state named "wrongCredentials" in case of error in your login page:
Function authenticationError()
If (Session.info.type#"remote")
Web Form.enableState("wrongCredentials")
End if
.setError()
.setError( msg : string)
| Parameter | Type | Description | |
|---|---|---|---|
| msg | string | -> | Error message to display in the web page |
Description
The .setError() function sends msg as an error message to the web page.
The function returns a response with a 200 OK status and a __WEBFORM object in the body with a __NOTIFICATION.message property set to msg and a __NOTIFICATION.type set to "error".
Example
shared singleton Class constructor()
exposed function myError()
var myForm : 4D.WebForm
myForm:=web Form
myForm.setError("My error message")
If the Provide feedback feature is enabled for the event, the message is automatically displayed as a red toast at the bottom of the Page and disappears automatically after 5 seconds:
.setMessage()
.setMessage( msg : string)
| Parameter | Type | Description | |
|---|---|---|---|
| msg | string | -> | Information message to display in the web page |
Description
The .setMessage() function sends msg as an information message to the web page.
The function returns a response with a 200 OK status and a __WEBFORM object in the body with a __NOTIFICATION.message property set to msg and a __NOTIFICATION.type set to "message".
Example
shared singleton Class constructor()
exposed function myMessage()
var myForm : 4D.WebForm
myForm:=web Form
myForm.setMessage("My information message")
If the Provide feedback feature is enabled for the event, the message is automatically displayed as a green toast at the bottom of the Page and disappears automatically after 5 seconds:
.setWarning()
.setWarning( msg : string)
| Parameter | Type | Description | |
|---|---|---|---|
| msg | string | -> | Warning message to display in the web page |
Description
The .setWarning() function sends msg as a warning message to the web page.
The function returns a response with a 200 OK status and a __WEBFORM object in the body with a __NOTIFICATION.message property set to msg and a __NOTIFICATION.type set to "warning".
Example
shared singleton Class constructor()
exposed function myWarning()
var myForm : 4D.WebForm
myForm:=web Form
myForm.setWarning("My warning message")
If the Provide feedback feature is enabled for the event, the message is automatically displayed as a yellow toast at the bottom of the web page and disappears automatically after 5 seconds: