Calling Operations on Static Server Pages

You can call operations on a static server page by extending the URL to include the operation name, or by specifying the operation in the Action URL attribute of the <form> element of a static server page. This provides a mechanism for sharing state information between USPs.

Calling an Operation From a URL

To call an operation from a URL, use the following syntax (assuming the Uniface default Web deployment environment):

http://HostServer:8080/uniface/wrd/ServerPageName{.OperationName{/InputPath} | {?InputData} }

  • HostServer—IP address or domain name of the machine where the WRD servlet is running
  • ServerPageName—name of a static server page
  • OperationName—name of an operation that does not have parameters defined in the signature.
  • InputPath—optional; string of input parameters in the form:

    Parameter/Value{/Parameter/Value}

    The InputPath is used for semantic URLs. Input path parameters are put into the PATHINPUT channel of $webinfo.

  • InputData—optional; string of input parameters in the form:

    Parameter=Value{&Parameter=Value}

    The list can contain name=value pairs or value-only parameters but not both. The InputData is used in non-semantic URLs.

    For dynamic server pages, the parameters are put in the HTTPREQUESTPARAMS channel of $webinfo.

    For static server pages, they are put into the INPUT channel of $webinfo.

Note:  Operations called from a URL cannot have parameters defined in their signatures. If you need to pass parameters, use $webinfo to read the parameters from the PATHINPUT or INPUT channels.

Operation: Find

For non-semantic URLs, it is preferable for InputData to contain an associative list of name=value pairs, using getitem/id to get the value using the name, and putitem/id to set the value. The model entity PERSON contains fields NAME and COUNTRY. A server page including the entity PERSON has an operation find

public operation find
variables
  string vList
endvariables

webget
vList = $webinfo("input")
if(vList = "")
  retrieve/e "PERSON"
else
  getitem/id NAME.PERSON, vList, "name"
  getitem/id COUNTRY.PERSON, vList, "country"
  retrieve/e "PERSON"
endif
webgen
end

When the server page is started with the following URL:

http://localhost:8080/uniface/wrd/personusp.find?name=John&country=USA

it retrieves the person matching the name and the country.

URL for USP operation with parameters

Calling an Operation Using the <form> Action Attribute

The <form> tag of a static server page has an action attribute (Action URL) that specifies the URL to which data in the browser is sent. By default, this attribute specifies the name of the current server page. For example:

<form method="POST" action="my_usp"...

When the data is submitted from the browser to the server, the exec operation of the specified server page is called.

To call a specific operation on a server page instead of the exec operation, edit the action attribute:

  1. In the Server Page Layout Editor, double-click the <form> tag or choose Form Properties from the pop-up menu.
  2. Specify an operation in the Action URL field using the following syntax:

    ServerPageName.OperationName{?InputData}

    For example:

    my_usp.myop

You can also edit the Action URL property in the HTML Source Editor of the Server Page Layout Editor.

Operation: Later

The first time a server page (my_usp) is called, some data needs to be initialized. Later, when the page is submitted to the server, the data initialization is not required. In this case, you can put the data initialization code in the exec operation, and define an operation to handle subsequent submissions.

For example, the operation later is defined as:

operation later
webget
webgen
end

Specify the operation in the action attribute of the <form> tag:

<form method="POST" action="my_usp.later" .....>

The code in the exec operation is executed only once. For the subsequent submit actions, the operation later is called instead of the exec operation.