SetSelfLink method (DataWindows)
Description
Specifies the URL and page parameters for the current page
of the Web DataWindow.
Controls
DataWindow type |
Method applies to |
---|---|
Web |
Server component |
Syntax
[Web DataWindow server component]
1 |
string <span>dwcomponent</span>.<span>SetSelfLink</span> ( string <span>selflink</span>, string <span>selflinkargs</span> ) |
Argument |
Description |
||
---|---|---|---|
dwcomponent |
A reference to an Web DataWindow server |
||
selflink |
The URL for the current page. It cannot Selflink is used to generate URLs for Sets the value of the HTMLGen.SelfLink property for the DataWindow |
||
selflinkargs |
A string in the form:
Argname is a page parameter to be passed Exp is a DataWindow string expression The evaluated selflinkargs expressions |
Return Values
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:
-
Login
information from another page -
DataWindow object name
-
Retrieval arguments for the DataWindow object
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:
1 |
String URI = request.getRequestURI(); |
1 |
String [] myArray = URI.split ("/"); |
1 |
String pageName = myArray [myArray.length-1]; |
In ASP, use the ServerVariables method
of the Request object:
1 |
var pageName =Request.ServerVariables( "SCRIPT_NAME" ); |
Self-link arguments for SetSelfLink
The syntax for specifying self-link arguments is:
1 |
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:
1 |
String logname = (String)    request.getParameter("Logname"); |
1 |
String linkargs = |
1 |
"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
This server-side script specifies hyperlink information
for the page. The value of the empid column is stored in the page
parameter EMPID:
1 |
webDW.<span>SetSelfLink</span>("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:
1 |
webDW.<span>SetSelfLink</span>("salesrpt.jsp", ""); |
This ASP example uses the ServerVariables method
of the Request object to get the SCRIPT_NAME variable:
1 |
var pageName =Request.ServerVariables( "SCRIPT_NAME" ); |
1 |
webDW.<span>SetSelfLink</span>(pageName,""); |
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:
1 |
String URI = request.getRequestURI(); |
1 |
String [] myArray = URI.split ("/"); |
1 |
String pageName = myArray [myArray.length-1]; |
1 |
String logname = (String)    request.getParameter("Logname"); |
1 |
String linkargs = |
1 |
"Logname='"" + logname + ""'"; |
1 |
webDW.<span>SetSelfLink</span>( pageName, linkargs); |