Opening a New Window

Sometimes you need to open a new window to a PeopleSoft page and when that windows opens you lose the state of your previous page. Here is a function that uses the PeopleSoft newwin servlet processing to open a new window in a new state block.

/*****************************************************************************
 NewWinUrl(&strUrl)
 
 This function modifies a URL to return a new window URL 
 It allows a new state block to be generated in a separate browser instance.
 http://server:port/psp/ps/EMPLOYEE/HRMS/c/...... 
 turns into 
 http://server:port/psp/ps_newwin/EMPLOYEE/HRMS/c/...... 
 which renders to the browser as 
 http://server:port/psp/ps_1/EMPLOYEE/HRMS/c/...... 
 
 Input parameters:  &strUrl - a URL to manipulate
 Output parameters: &strUrlModified - New URL with _newwin parameter
 
 ****************************************************************************/
 
Function NewWinUrl(&strUrl As string) Returns string;
   Local string &sRegex, &sReplace, &Result;
   /* Declare java object */
   Local JavaObject &jUrl;
 
   /**
    * Peoplesoft Content types:
    * -------------------------
    * Component: c
    * Script: s
    * External: e
    * Homepage: h
    * Template: t
    * Query: q
    * Worklist: w
    * Navigation: n
    * File: f
   **/
 
   /* Regex strings */
   /*          psc/psp  Site      Portal    Node      Content Type */
   &sRegex = "/(ps[cp])/([^\/]*)?/([^\/]*)?/([^\/]*)?/([csehtqwnf]{1})/";
   &sReplace = "/$1/$2_newwin/$3/$4/$5/";
 
   /* Instantiate objects and replace */
   &jUrl = CreateJavaObject("java.lang.String", &strUrl);
   &Result = &jUrl.replaceAll(&sRegex, &sReplace);
 
   /* Return modified URL */
   Return &Result;
End-Function;
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License