WebForm
The 4D.WebForm
class object provides an interface that allows you to handle your Page components. 4D.WebForm
objects are instantiated with the webForm
command.
Functions and properties
.componentName
.componentName* : 4D.WebFormItem
Description
The components of Pages are objects that are available directly as properties of these Pages.
The returned objects are of the 4D.WebFormItem
class. These objects have functions that you can use to manage your components dynamically.
Example
var myForm: 4D.WebForm
var component: 4D.WebFormItem
myForm = webForm //returns the page as an object, each property is a component
component = myForm.myImage //returns the myImage component of the 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 Page |
Description
The .disableState()
function disables the rendering of the state in the current Page.
This function does nothing if:
- the state is currently not enabled in the Page,
- the state does not exist for the 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 Page states, please refer to the States section.
.enableState()
.enableState( state : string)
Parameter | Type | Description | |
---|---|---|---|
state | string | → | Name of state to enable on the Page |
Description
The .enableState()
function enables the rendering of the state in the current Page.
This function does nothing if:
- the state has already been enabled on the Page,
- the state does not exist for the 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 Page states, please refer to the States section.
.setError()
.setError( msg : string)
Parameter | Type | Description | |
---|---|---|---|
msg | string | → | Error message to display in the Page |
Description
The .setError()
function sends msg as an error message to the 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
exposed function myError()
webForm.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:
See also
.setMessage()
.setMessage( msg : string)
Parameter | Type | Description | |
---|---|---|---|
msg | string | → | Information message to display in the Page |
Description
The .setMessage()
function sends msg as an information message to the 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
exposed function myMessage()
webForm.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 Page |
Description
The .setWarning()
function sends msg as a warning message to the 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
exposed function myWarning()
webForm.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 Page and disappears automatically after 5 seconds: