Focal Point
[SOLVED] Capture URL parameters inside FEX in PORTAL

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5577023376

October 30, 2014, 11:11 AM
WFConsultant
[SOLVED] Capture URL parameters inside FEX in PORTAL
The portal page is run from a URL. The URL has parameters passed in the query string. These parameters are not available in the fex (report) inside the portal. I will appreciate help with any technique.

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 8207.11
App Studio 8207
November 04, 2014, 11:50 AM
Francis Mariani
Please provide an example of the URL. The parameters are definitely not available in the fex - it seems like there's nothing we can do between the BIP URL and the individual fexes...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 05, 2014, 08:38 AM
njsden
WFConsultant, as far as I know, parameters passed to the URL are only made available to the .fex only when its execution is invoked via WFServlet. The URL to run a Portal seems to use a RESTful-like call (wich may/may not use WFSerlvet behind the scenes) but because the target call is not really a .fex perhaps the infrastructure doesn't care or can't expose those parameters as &variables.

The only way I would attempt to achieve what you want is to create an HTML Composer page with your target report in an iframe and hidden parameters. You would use JavaScript to "read" the URL from the Portal call and parse the parameters from there, setting the appropriate HTML controls to those values and then trigger your report to be executed. Yes, this seems like a lot of work and you'll end up with an iframe within an iframe but I can't think of an easier way Frowner

This message has been edited. Last edited by: njsden,



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
November 05, 2014, 09:46 AM
Francis Mariani
If the URL is a Portal URL, it looks something like this:

http://my-web-server/ibi_apps/bip/portal/MyPortal


and if you add parameters, it might look like this:

http://my-web-server/ibi_apps/bip/portal/MyPortal&PARM1=haha&PARM2=crycry


Viewing the source of the page after the Portal loads, you get something like this:

<!DOCTYPE html>

<html>
	<head>
	    <title>BI Portal</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" >		
		<meta http-equiv="MsThemeCompatible" content="yes">
		<meta http-equiv="ImageToolBar" content="no">
		<link type="text/css" rel="StyleSheet" href="/ibi_apps/bindows/css/bimain.css">
		<script type="text/javascript" src="/ibi_apps/bindows/js/application.js"></script>
	</head>
	<body>
		<script type="text/javascript">application.start("/ibi_apps/bindows", "/ibi_apps/tools/portal/resources/markup/wfbiportalrun.jsp?&ViewID=MyPortal&ViewName=MyPortal&ViewTitle=MyPortal&SessionTimeout=7200000")</script>
	</body>
</html>


You see this?

/ibi_apps/tools/portal/resources/markup/wfbiportalrun.jsp?&ViewID=MyPortal&ViewName=MyPortal&ViewTitle=MyPortal&SessionTimeout=7200000


You cannot retrieve something as simple as these variables: &ViewID, &ViewName and &ViewTitle - they're not available in fexes that are run within the portal, neither are they available to add via site.wfs. To me this seems ludicrous.

A fex run within the portal has a URL such as this:

http://my-web-server/ibi_apps/view.bip?BIP_REQUEST_TYPE=BIP_LAUNCH&BIP_folder=IBFS%253A%252FWFC%252FRepository%252Fdomain01%252Fstd_reports%252Fmrefolder001&BIP_item=homepage_launch.fex&WF_STYLE_HEIGHT=783&WF_STYLE_WIDTH=1914&WF_STYLE_UNITS=PIXELS&IBIWF_redirNewWindow=true&WF_STYLE=IBFS%3A%2FFILE%2FIBI_HTML_DIR%2Fjavaassist%2Fintl%2FEN%2Fcombine_templates%2FENInformationBuilders_Medium1.sty&WF_THEME=BIPCustom&BIP_CACHE=100000&BIP_rand=4718
I would love to know how homepage_launch.fex, which could contain some HTML, could determine the parameters passed by that JSP call or determine the additional parameters passed in the portal call. As far as I can tell, the fex is living within it's own world, unaware it's running within a portal.

I've wanted to determine the name or ID of the B.I. Dashboard/Portal since WebFOCUS 5.3. According to a case I opened some time ago, this functionality apparently showed up for a very short time in WF v7.7.02 and then disappeared in WF v7.7.03 (or it never worked).

I've given up asking for it.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 05, 2014, 02:20 PM
njsden
Something like this?



I just added some JavaScript in the onInitialUpdate() to the launch .htm file that sits inside of the portal panel:

function onInitialUpdate() {
   var edit1 = document.getElementById('edit1');

   // Capture window's URL and parse parameter to be passed to the .fex
   var mainURL = parent.window.location.href;

   var comps = mainURL.split("?");
   
   // See if there are actual URL parameters
   if(comps.length > 1) {
      var params = comps[1].split("&");

      // Loop thru URL params looking for P_COUNTRY
   
      for (var i = 0; i < params.length; i++) {
         var p = params[i].split("=");

         // If P_COUNTRY is found in URL, use it as value to pass to the report
         if("P_COUNTRY" === p[0]) {
           edit1.value = p[1];
         }
      }
   }
}


The code is far from elegant but it's there to illustrate the concept. By the way, the launch page was created with HTML Composer in Dev Studio 8008.

Hope this helps.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
November 05, 2014, 02:24 PM
njsden
I should have mentioned that the main trick here is to explore the parent's window location as opposed to the one in the current iframe which actually contains a different URL resulting from an internal redirection to view.bip and other stuff IBI knows better Smiler



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
November 05, 2014, 03:38 PM
Francis Mariani
quote:
parent.window.location.href
- that is what we need! Thanks.

Now I have to work out how to capture the Portal Name and/or the variables BEFORE a report executes in a section of the Portal window - a report that normally wouldn't have any HTML around it...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 05, 2014, 06:14 PM
WFConsultant
@ njsden , thank for the example. After capturing the parameters using similar JavaScript function, we have set them to hidden variables. Later, pushed the values to the reports (fex) using ‘parent.BipIframeInterface.setAllAmpersValues(name,IbComposer_getAllAmpersValues());’. Like you have said it is not ‘elegant’, but gets the work done.


WebFOCUS 8207.11
App Studio 8207
November 05, 2014, 10:03 PM
njsden
I'm glad to hear it helped. Now you've just given me homework as I want to research about parent.BipIframeInterface.setAllAmpersValues method Smiler

At our shop we are just in the process of upgrading to WF8 from WF77 and this whole Portal stuff is new to us. Lots to learn (and sometimes to suffer) from!



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.