This sample can be accessed from:
portal-server-URL/rewriter/JavaScript/variables/expr/expr.html
Add the rule specified in this sample (if it does not already exist) to the default_gateway_ruleset in the section "Rules for Rewriting JavaScript Source".
Edit the default_gateway_ruleset in the Rewriter service under Portal Server Configuration in the Portal Server administration console.
If you added the rule, restart the Gateway:
./psadmin start-sra-instance –u amadmin – f <password file> –N <profile name>– t <gateway> |
<html> <head> <title>JavaScript EXPRESSION Variables Test Page</title> </head> <body> <script LANGUAGE="Javascript"> <!-- //Expression variables var expvar1="images"; var expvar2="/logo.gif"; var expvar = expvar1 + expvar2; document.write("<A HREF="+expvar+">EXPRESSION</A><P>") var expvar="/images/logo"+".gif"; document.write("<A HREF="+expvar+">EXPRESSION</A><P>") //--> </SCRIPT> Testing JavaScript EXPRESSION variables </body> </html>
<Variable type=”EXPRESSION” name="expvar"/>
<html> <head> <title>JavaScript EXPRESSION Variables Test Page</title> </head> <body> <SCRIPT> // Rewriter appends the wrapper function psSRAPRewriter_convert_expression here </SCRIPT> <script LANGUAGE="Javascript"> <!-- //Expression variables var expvar1="images"; var expvar2="/logo.gif"; var expvar =psSRAPRewriter_convert_expression( expvar1 + expvar2);
// Rewriter recognizes the right hand side of this statement to be a JavaScript EXPRESSION variable. Rewriter is not able to resolve the value of this expression at the server end. Hence, the psSRAPRewriter_convert_expression function is prefixed to the expression. The expression is evaluated at the client end, and rewritten as required.
document.write("<A HREF="+expvar+">EXPRESSION</A><P>")
// The rewritten value of expvar from the previous statement is used to arrive at the value of this expression. Because the result is a valid URL (a graphic exists at this location in the sample), the link will work.
var expvar="gateway URL/portal-server-URL/images/logo"+".gif";
// Rewriter recognizes the right hand side of expvar to be a string expression. This can be resolved at the server side, and hence is rewritten directly.
document.write("<A HREF="+expvar+">EXPRESSION</A><P>")
// The rewritten value of expvar from the previous statement is used to arrive at the value of this expression. Because the result is a not a valid URL (a graphic does not exist at the resultant location), the link will not work.
//--> </SCRIPT> Testing JavaScript EXPRESSION variables </body> </html>