webget

Load data from a client request into a static server page (USP), reconnect to the database if applicable, set current occurrence, and activate a detail or error trigger if required.

webget

Return Values

Values returned in $status
Value Meaning
0 No errors detected and all field values transferred, or error trigger is empty.
<0 An error occurred. The value may be returned by the error trigger, or it is returned by $procerror.

Note: It is recommended that you always check the value of $procerror after webget and before webgen.

Values of $procerror commonly returned by webget
Value Error constant Meaning
-31 <UGENERR_LICENSE> No license available for the requested action. Contact your Uniface representative
-35 <UGENERR_4GL_SAYS_ERROR> The error or detail trigger returned a (user-defined) negative value in $status. For more information, see Return Values from Triggers.
-255 <UWEBERR_NO_CGI> The webget statement was used in a non-web context. It must be used in a web runtime environment ($web!="").
-256 <UWEBERR_NO_INPUT_EXPECTED> No further input expected, because no fill-out document has been generated.
-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.
-258 < UWEBERR_STEP> Synchronization error, that is, the user has submitted an HTML document that does not correspond to the last one generated. It is, instead, an HTML page generated by Uniface earlier in the same session.
-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.
-260 <UWEBERR_OCC_REJECTED> A new occurrence was encountered in the data submitted from the static server page and caused that data to be rejected.

Use

Use in Static Server Page components.

Description

When a request is sent by the web client, webget is responsible for loading the request data into the component. This entails the following steps:

  1. Load an interpret the request information in $webinfo("input").
  2. If applicable, reconnect occurrences with the database to check for concurrency problems. Any data concurrency conflicts are handled by the business logic.
  3. Set the context by setting the current occurrence.
  4. Fire the detail trigger or an error trigger, if necessary.

For more information, see Processing Requests and Responses for Static Server Pages.

Loading the Client request

The webget statement loads data that was submitted from a client browser into the current USP (on the server). It creates new occurrences for each occurrence on the HTML request, and reconnects occurrences that are already stored in the database to the database occurrence.

The webget statement creates a new occurrence when required. If the first field of a new occurrence corresponds with a Uniface command button, webget remembers this button and fires the detail trigger after processing all input. Only one command button is remembered.

Note: The detail trigger of all command buttons must contain a public web declaration. Otherwise, webget returns error -257 <UWEBERR_ILLEGAL_ACT> and clears the component.

The webget statement clears the input buffer after processing. Subsequent calls to webget do not produce any action.

webget has its own procedure for handling errors. For more information, see Data Error Handling in Web Applications.

Processing Occurrences Created in the Client

The way that webget handles new occurrences that have been created in the client depends on the value of the assignment setting $USP_CHECK_NEW_OCC. If this is not present, or it is set to off, webget creates a new occurrence on the server and continues processing.

If the assignment file contains $USP_CHECK_NEW_OCC{=on}, webget sets $error to 2014 causing the entity's error trigger to be fired. You can use ProcScript in the error trigger to inspect the incoming field data of this new occurrence and decide what to do with it.

For example, you can use discard to remove the occurrence before proceeding.

Important: You cannot discard records in the error trigger in any other situation, so you must explicitly test for $error="2014" before you perform a discard.

If you expect new occurrences created in the client, you can return 0 in the error trigger. webget continues processing and will include the new occurrence when data is stored.

If you return a negative value in the error trigger, webget stops further processing and clears the component. The detail trigger is not fired and error -260 <UWEBERR_OCC_REJECTED> is returned.

Reconnecting Occurrences to the Database

A USP is a stateless component that is only active for the duration of a user request. When an XHTML page is created, Uniface adds additional information about each occurrence.

A hidden field is added at the beginning of each occurrence with information about its database state. The name of this field starts with a hash character (#). If the occurrence was already stored in the database, the partially-encoded primary key is included, so that Uniface can restore the database context in the next request.

A non-database entity is preceded by a percent sign (%). In this case, no attempt is made to reconnect to the database.

Related Topics