Consultor Eletrônico



Kbase P102533: WebSpeed API: How to use the set-user-field and get-user-field functions?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/25/2005
Status: Unverified

GOAL:

How to use the set-user-field and get-user-field WebSpeed API Functions?

FIX:

The following sample html script demonstrates the use of the set-user-field and get-user-field WebSpeed API Functions. This code has been successfully tested against the Sports2000 demo database using Progress Version 9.1D environment:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>WebSpeed Script</title>
</head>
<body>
<p><center><b>Enter either 2 or 3</b></center></p>
<script language="SpeedScript">
DEFINE VARIABLE v-cust AS CHARACTER.
/* get the value supplied from the browser, if any */
v-cust = get-value('cust-nbr').
/**************************************************************************/
/* NOTE!!!! The above function cannot be a get-user-field because */
/* set-user-field hasn't been applied yet. The difference with get-value */
/* and get-user-field is that get-value looks for the field name in the */
/* following locations : */
/* - user field list */
/* - HTML form fields (including hidden fields) */
/* - URL query string name/value pairs */
/* - cookie names */
/* */
/* Get-user-field only gets its information from the user field list. */
/* */
/* WebSpeed user fields are a shared list of field names and associated */
/* values that can be set or accessed from any WebSpeed procedure within */
/* a single browse request. &.nbsp; */
/* */
/* It is important to remember that user fields persist for only a single */
/* browse request. As long as the objects you run do not return out to */
/* the Web server, the values you set in user fields will be accessible */
/* by all of them. Each time a browser user request comes in to a */
/* WebSpeed Agent, the user fields are cleared. */
/**************************************************************************/
IF v-cust = " " /* no value from browser, use default of 1 */
THEN set-user-field('cust-nbr',"1").
/* initial apply of set-ser-field */
/* If user enters cust num 2, display customer 10 instead! */
IF v-cust = "2"
THEN set-user-field('cust-nbr',"10").
/* If user enters cust num 3, display customer 20 instead! */
IF v-cust = "3"
THEN set-user-field('cust-nbr',"20").
/* Now call get-user-field in case cust-nbr has changed due to any
of the set-user-field calls above */
FIND customer
WHERE custnum = INTEGER(get-user-field('cust-nbr')) NO-LOCK.
/* No problem using get-user-field here, because set-user-field has been applied */
</script>
<form action="`SelfURL`" method="POST">
<p><center><strong>Jump to:
<input type="text" size="20"
name="cust-nbr" value="`custnum`">
<input type="submit" name="submit-search" value="Submit">
<BR> Name: `html-encode(name)`
</center></strong></p>
</form>
</body>
</html>.