Object
Actions are written in standard JavaScript, but development requires the use of an action-specific object. An object is structural data that holds data. Objects include $ui and $const, which have preregistered properties, and $param and $session, to which properties can be added arbitrarily. There is also $req and $res which can only be used in REST API actions.
Object | Purpose | Description |
---|---|---|
$ui | Access to UI components | Can set/get values for registered properties |
$param | Data transfer to the next ui | Can set/get any property |
$session | Data transfer during a session | Can set/get any property |
$const | Constant Reference | Possible to retrieve registered constant values |
$req | Request data | Obtain HTTP request object in REST API action |
$res | Response data | Set HTTP response object in REST API action |
Tips
$ui
$ui is an object that represents the UI that defines the action. components placed in the UI can be retrieved as property values. It also indicates the state of the component as it appears in the UI after the action is executed.
Obtaining component values during action execution | Example: const val = $ui.text_field_1.value; |
Set component values after action execution | Example: $ui.text_field_1.value = val; |
The above shows an example of getting the value of a text field when an action is executed and an example of setting the value of a text field after the action is executed.
A component has not only a value, but also various other properties such as color, variants, etc. that decorate the component. They can be acquired/configured in the same way in the action.
Tips
$this
$this is an object that indicates the component that is executing the action. It can be used to obtain the property value of the component itself that is placed in the UI.
The available properties vary depending on the part, so they may not exist depending on the component that performed the action.
It is also possible to use functions that can be used commonly within an application, such as global functions. In the action of the component with ID "text_field_1"
, you can replace it with $this without entering the component ID, such as $ui.text_field_1.value.
Tips
$param
$param is a parameter object that sends arbitrary data to the next UI screen. Scope is up to the next UI screen. You can add any property in $param as follows
$param.name = “Adam”;
$param.age = 26;
You can receive $param in the onload action of the target UI.
const name = $param.name;
const age = $param.age;
Tips
$session
$session is a session object that manages arbitrary data during a session. The scope is the duration of the session. Arbitrary properties can be added and retrieved as well as parameters.
Tips
Session Duration
For authentication applications
Session duration is during the sign-in period.
Tips
For unauthenticated applications
The duration of a session can be up to 24 hours from the time the application is displayed.
However, even within the duration of the session, it becomes invalid when the browser is closed.
$global
$global is an object for referencing the global functions you created. You can use global functions that are managed within your application. Example) const result = await $global.myFunction()
$const
$const is an object for referencing registered constants. You can retrieve the constant value using the name of the constant managed in the application. Example)$ui.nameField.label = $const.nameLabel;
Tips
$req
$req is an HTTP request object that can be used within a REST API action. Use the $req object to retrieve request data.
Refer to the Amazon Gateway API page for more information on the properties of the $req object.
Property | Type |
---|---|
body | string |
headers | Object |
httpMethod | string |
isBase64Encoded | boolean |
multiValueHeaders | Object |
multiValueQueryStringParameters | Object |
Path | string |
pathParameters | Object |
queryStringParameters | Object |
requestContext | Object |
resource | string |
stageVariables | Object |
$res
$res is an HTTP response object that can be used within a REST API action. Use the $res object to set the response data to be returned.
Refer to the Amazon Gateway API page for more information on the properties of the $res object.
Property | Type |
---|---|
body | string |
headers | Object |
isBase64Encoded | boolean |
multiValueHeaders | Object |
statusCode | number |