Return Values
Value | Meaning |
---|---|
>0 |
JSON stream loaded, but could not find all the field and entity names specified in the default and local mappings. For each field not found, $status is incremented by 1. More information is available in the message frame if the assignment setting $TEST_MODE_COMPONENTS is set. |
0
|
JSON stream successfully loaded |
<0 |
An error occurred. $procerror contains the exact error. |
Value | Error constant | Meaning |
---|---|---|
-257
|
<UWEBERR_ILLEGAL_ACT>
|
One or more fields cannot be accessed. This occurs when field names mentioned in the HTML page are not available in the current component in Uniface. For example, if the Detail trigger of a command button does not contain a public web declaration. |
-259
|
<UWEBERR_HASH>
|
Mismatch between the security hash of a field and the field value. This can occur when the value of a NED field has been modified by the browser or other web user agent. |
-261
|
<UWEBERR_DATA>
|
An error occurred while loading data. Incorrect data values or data formats were encountered during server-side validation of a Date, Time, or DateTime field. |
Use
Allowed in all component types.
Description
The webload statement transfers
data from a JSON stream into a component. The data is loaded from the
$webinfo("data")
channel directly into the component's data
structure.
webload checks for JSON parsing errors, mismatched hash security values for NED fields, and incorrect field values and data formats in Date, Time, or DateTime fields. However, it does not interpret or initiate other data validation, so the data loaded by webload can include duplicates of occurrences already within the component, as well as occurrences marked for deletion.
All occurrences loaded from a data stream (including occurrences marked for deletion) are displayed on forms and accessible in ProcScript.
You can use the $JSON_INDENT and $JSON_SHOWNAMES assignment settings to make the JSON stream more human-readable for development and debugging purposes.
Reconnect Loaded Data
The webload statement also sets occurrence modification properties used by reconnect. After every webload statement, you should use a reconnect statement to reconnect the loaded data with the data in the component and the database (if connected). reconnect removes duplicates of occurrences, removes occurrences marked for deletion from the component, and sets the appropriate modification flags.
Triggers Fired by webload
The webload statement fires the following triggers that can be used to customize how a JSON stream is loaded into a component:
- trigger preDeserialize—fired immediately before an occurrence is loaded into a component. The new occurrence is not yet available and cannot be accessed.
- trigger postDeserialize—fired immediately after an occurrence is loaded into a component, and after all error triggers caused by validation errors. The new occurrence is available and can be accessed. For example, use this trigger if an occurrence can be discarded, or the value for a derived field can be calculated.
The following example loads a text file containing JSON-formatted data with Japanese characters and data for a dummy entity.
The component structure contains one database entity JAPAN.JAPAN and a non-database entity containing two buttons.
The following JSON data loads the data for both derived database fields and for non-database component fields.
Note: By default, fields and entities in JSON streams
are identified by ID. Fully-qualified names for fields and entities are shown in the
nm
attribute only when you use the $JSON_SHOWNAMES assignment
setting.
{ "#2" : { "nm" : "JAPAN.JAPAN", "type" : "entity", "occs" : [ { "id" : "BhJDMTIzNA==", "crc" : "00000021", "status" : "est", "#3" : { "nm" : "ID.JAPAN.JAPAN", "value" : "1234" }, "#4" : { "nm" : "BRAND.JAPAN.JAPAN", "value" : "SONY" }, "#5" : { "nm" : "DESCRIPTION.JAPAN.JAPAN", "value" : "\u3044\u307E" } } ] }, "#6" : { "nm" : "ENTITY.JAPAN", "type" : "entity", "occs" : [ { "id" : "VE1QOjQ3ODM0M2RhXzFfYmJmNTAw", "crc" : "", "status" : "new", "#7" : { "nm" : "PB1.ENTITY.JAPAN", "value" : "MickeyMouse" }, "#8" : { "nm" : "PB2.ENTITY.JAPAN", "value" : "DonaldDuck" } } ] } }
Version |
Change |
---|---|
9.4.01 |
Introduced |