websave

Creates a JSON stream from the data in a component.

websave{/mod | /one}

Switches

  • /mod—includes only modified occurrences in the JSON stream

  • /one—includes only current outer occurrence (with all inner occurrences) in the JSON stream

Return Values

The output of websave returns the CRC, ID, and STATUS for every occurrence and is put in the $webinfo("data") channel.

Values returned in $status

Value

Meaning

<0

An error occurred. $procerror contains the exact error.

0

Success

>0

Number of images for which a temporary file could not be created.

Use

Allowed in static and dynamic server page components.

Description

The websave statement creates a JSON stream from the data in a component. The stream is built from the complete hitlist, including occurrences currently marked for deletion. Occurrences and fields are selected from the data set based on switches used by the websave statement.

The entities and fields included in the stream are defined by the component structure, so both database and non-database fields are included in the JSON stream.

You can use the $JSON_INDENT and $JSON_SHOWNAMES assignment settings to make the JSON stream more human-readable for development and debugging purposes.

Triggers Fired by websave

The following triggers are fired by the websave statement and can be used to customize the process of saving a component into an JSON stream:

  • Pre Save Occurrence—fired immediately before an occurrence is saved from a component into a JSON stream. The occurrence is available and can be examined. For example, the value for a derived field can be calculated.

  • Post Save Occurrence—fired immediately after an occurrence is saved from a component into an JSON stream.

Images

When the component contains images from a database, the Uniface Server creates temporary image files in the project directory. If it does not have write privileges for the project directory, this action fails. The page is still presented to the browser, but with image load error icons in the locations of the images.

The following code creates a JSON stream from a component's data structure and writes the result to the message frame.

clear
retrieve/e "ORDER.INOUTER"
websave
putmess $webinfo("data")
return
History

Version

Change

9.4.01

Introduced