SetSelfLink

Description

Specifies the URL and page parameters for the current page of the Web DataWindow.

Applies to

DataWindow type

Method applies to

Web

Server component

Syntax

Web DataWindow server component

string dwcomponent.SetSelfLink ( string selflink, string selflinkargs )

Argument

Description

dwcomponent

A reference to an Web DataWindow server component.

selflink

The URL for the current page. It cannot include parameters. Parameters may be added when HTML is generated.

Selflink is used to generate URLs for navigation buttons that obtain additional rows from the result set and for other buttons that reload the page, such as Update and Retrieve.

Sets the value of the HTMLGen.SelfLink property for the DataWindow object associated with the server component.

selflinkargs

A string in the form:

argname='exp'{ | argname = 'exp' } ... 

Argname is a page parameter to be passed to the server.

Exp is a DataWindow string expression that is evaluated, converted using URL encoding, and used as the value of argname in generated HTML.

The evaluated selflinkargs expressions are included in the generated HTML as hidden fields. The arguments supply information, such as retrieval arguments, that the server needs to render additional pages of the result set.

Returns

Returns an empty string if successful and the syntax error message from the Modify method if it fails.

Usage

This method calls the Modify method of the server component’s DataStore to set the property.

For information about using the Web DataWindow, see the DataWindow Programmers Guide.


Reason for self-link information

The first time the client browser requests the page template, it can pass page specific information using GET or POST and the page can use those values in the server-side scripts. However, when the page is reloaded because of user interactions with the Web DataWindow, that information will not be passed to the page automatically.

To make the information available, you specify a selflinkargs string that becomes page parameters in the reloaded page. Typically, you would use self-link parameters to provide:


Getting the URL for the page

To correctly reload the page in response to user actions, the server component needs to know the URL of the page template. You can get this information from the name property of the document object header or the SCRIPT_NAME server variable.

In a JSP page, you must parse the return value from a request.getRequestURI call:

String URI = request.getRequestURI();

String [] myArray = URI.split ("/");

String pageName = myArray [myArray.length-1];

In ASP, use the ServerVariables method of the Request object:

var pageName =Request.ServerVariables( "SCRIPT_NAME" );


Self-link arguments for SetSelfLink

The syntax for specifying self-link arguments is:

pageparam='expression'|pageparam='expression'

The expression is a DataWindow expression that is evaluates to a string. Usually, you will be passing constant string values that have already been passed to the page as page parameters.

The expression is enclosed in quotes, and if the value is a constant, it must also be enclosed in quotes. For example, if a page parameter has the value Johnson, the value of the expression must be enclosed in two sets of quote marks: '"Johnson"'.

To get the value from the current Logname parameter, which is already defined for the page, you build the expression using the Logname page parameter. The single quotes and inner double quotes are embedded in the expression. The current value is inserted between the quotes:

String logname = (String)    request.getParameter("Logname");

String linkargs = 

		"logname='\"" + logname + "\"'";

If the DataWindow object requires retrieval arguments, they must be provided to the reloaded page in selflinkargs. For an example of using SetSelfLink for setting up retrieval arguments as page parameters, see Retrieve.

Examples

Example 1

This server-side script specifies hyperlink information for the page. The value of the empid column is stored in the page parameter EMPID:

webDW.SetSelfLink("mydwpage.html", "EMPID =   'String(empid)'");

This hyperlink information refers to the JSP page by name. The page is regenerated by calling the template again. There are no link arguments:

webDW.SetSelfLink("salesrpt.jsp", "");

Example 2

This ASP example uses the ServerVariables method of the Request object to get the SCRIPT_NAME variable:

var pageName =Request.ServerVariables( "SCRIPT_NAME" );

webDW.SetSelfLink(pageName,"");

Example 3

In JSP you must parse the return value from a request.getRequestURI call. This example also sets up a page parameter for the reloaded page using the page parameter Logname:

String URI = request.getRequestURI();

String [] myArray = URI.split ("/");

String pageName = myArray [myArray.length-1];

String logname = (String)    request.getParameter("Logname");

String linkargs = 

		"Logname='\"" + logname + "\"'";

webDW.SetSelfLink( pageName, linkargs);

See also