Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Displaying ALL Parameters

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Displaying ALL Parameters
 Login/Join
 
Gold member
posted
Hello Everybody,

I want to write a WebFOCUS procedure that will display all parameters submitted to it from an HTML form. I'm using the WFServlet.

I want the program to be generic so that it will work no matter what launch page I use. Any ideas?

Thanks for your help.
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
Silver Member
posted Hide Post
Not sure what you mean by "display". For instance, if you put on the first line of your fex the command
-SET &ECHO=ALL;  
you will get all the values in your fex showing up in the echo. You can view this when your report displays by right clicking on the display page in your browser and selecting "view source". (just scroll to the bottom, and you will see your focexec source) If you want to show the values in the report heading or footing, then you can just place all the amper variables into the appropriate heading/footing lines.

If I missed what you are looking for, let me know. I do a lot of work with DM, maybe I can help you.
 
Posts: 44 | Location: New York City | Registered: May 23, 2004Report This Post
Gold member
posted Hide Post
I'm not interested in viewing the focexec code.

If I have a launch page with several HTML parameters in it, I would like to be able to submit the page to the WFServlet, and have it run a focexec that echoes back the names of the parameters submitted and their values. I want the procedure to be generic, so that I can use it with any launch page I choose.

The focexec executed by the WFServlet cannot presume to know the names of any of the parameters passed in. It simply must know how to get at those parameters and echo them back to the requestor.

Hope that's clearer. Any ideas are appreciated.
Thanks.
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
Silver Member
posted Hide Post
try:

-SET &ECHO=ALL;
-? &
-EXIT

in a focexec that you call with parameters. You will get several other, standard, values as well (like the date) but your passed parm values will be in there as well.

hth,

drew
 
Posts: 46 | Location: San Francisco, California | Registered: April 14, 2003Report This Post
Gold member
posted Hide Post
This is helpful. Thank you.

I would really like to be able to sift out the system and statistical variables and present only those variables in the launch page. Is there any way to pass the parameters presented by '-? &' into an array where they could be processed using -REPEAT and index variables?
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
Gold member
posted Hide Post
Well this is what I finally came up with. Perhaps it will be of benefit to someone else. I had to go outside the bounds of WebFOCUS to get the functionality I wanted. I wrote a JSP that creates a PARAMS parameter that contains the names of the parameters submitted in the form, and then wrote a simple focexec to display the names and the values of the parameters in the PARAMS array.

I think IBI should offer this functionality, if they don't do so already by some means unknown to me. If this functionality exists within WebFocus would someone please tell me so that I can bag this JSP!

Here is the java server page:

<%-- Build a params parameter. Pass it to the WFServlet. --%>

<%@ taglib uri='http://java.sun.com/jstl/core' prefix='c' %>

<c:redirect url="http://mydomain/ibi_apps/WFServlet">
<c:forEach items="${paramValues}" var="parameter">
<cRazzeraram name="PARAMS" value="${parameter.key}" />
<c:forEach items="${parameter.value}" var="value">
<cRazzeraram name="${parameter.key}" value="${value}" />
</c:forEach>
</c:forEach>
</c:redirect>

And here is the focexec:

-* Echo parameters in form. Relies on JSP to set up &PARAMS.

-*
-SET &LIMIT = &PARAMS0;
-REPEAT LOOP FOR &COUNTER FROM 1 TO &LIMIT.EVAL STEP 1
-SET &MYPARM0 = 'PARAMS' | &COUNTER;
-SET &MYPARM1 = '&' || &MYPARM0;
-SET &MYPARM2 = '&' || &MYPARM1.EVAL;
-IF &MYPARM2.EVAL.EXISTS EQ 0 THEN GOTO NULLVALUE;
-TYPE &MYPARM0.EVAL: NAME=&MYPARM1.EVAL VALUE=&MYPARM2.EVAL
-GOTO NEXT
-NULLVALUE
-TYPE &MYPARM0.EVAL: NAME=&MYPARM1.EVAL VALUE=NULL
-GOTO NEXT
-NEXT
-LOOP
-EXIT
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
<Pietro De Santis>
posted
Here is a fex that can be included at the beginning of any fex called by an HTML form. This uses JavaScript.

  

-*
------------------------------------------------------------------------------
-* Program Name: showvars.fex
-* Description : Display all FOCUS variables in a browser window
-* Developer   : Pietro De Santis
-* Date Written: July, 2004
-*------------------------------------------------------------------------------
-HTMLFORM BEGIN
<html>
<head>
<title>Display all WebFOCUS variables</title>
<script type="text/javascript" language="JavaScript">
// Function to extract and display all FOCUS variables passed via the CGI
function ExtractFocusParms()
{//  alert(document.URL);
//  alert(location);
var ParmIndex = 0;
// Strip away leading question 
mark.var input = location.search.substring(1);
// Divide long string into array of name/value pairs.
var srchArray = input.split("&")
var tempArray = new Array()
for (i = 0; i < srchArray.length; i++) 
 {  
// Divide each name/value pair temporarily into a two-entry array.  
tempArray = srchArray[i].split["=")  
// Write HTML code that displays the contents of the variables  
// Unescape returns an ASCII string for the hexadecimal value  
// It undoes the escape function performed in the sending program  
document.write('<tr>' +
    '<td class=cssVarName>'  +
 unescape(tempArray[0]) +
 '</td>' +
    '<td class=cssVarValue>' +
 unescape(tempArray[1]) + 
 '</td>' + 
'</tr>');
ParmIndex= ParmIndex + 1;  
}
}
</script>
<style type="text/css">
.cssVarName {font-family: Verdana, sans-serif; font-size: 11px; font-weight: bold;
     padding: 2px; background-color: #D8D8BF;}
.cssVarValue {font-family: Verdana, sans-serif; font-size: 11px; padding: 2px;  
     background-color: #D8D8BF;}
.cssFormLabel {font-family: Verdana, sans-serif; font-size: 11px; font-weight: bold; }
.cssButton    {font-family: Verdana, sans-serif; font-size: 11px; font-weight: bold;
     cursor:hand; }
</style>
</head>
<body style="margin: 2px;">
<center>
<div class="cssFormLabel">List of variables passed by the WebFOCUS Report Request:</div>
<form action="" method="get">
  <input type="button" class="cssbutton" value="Close" onClick="window.close();">
</form>
<table border="0" cellpadding="0" cellspacing="2">
<script language="JavaScript">ExtractFocusParms();</script>
</table>
<form action="" method=get>  
  <input type="button" class="cssbutton" value="Close" onClick="window.close[);">
</form>
</body>
</html>
-HTMLFORM END
-EXIT

This message has been edited. Last edited by: Kerry,
 
Report This Post
Gold member
posted Hide Post
This is interesting. The code is parsing the GET request. I'll give it a whirl. Thank you.
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
Gold member
posted Hide Post
Here's another way to get at a list of parameters within WebFocus. This method allows you to write "generic" focexecs that do not have to know the names of the parameters being passed to the program.

In order to get this to work, you place into Tomcat a "filter", that intercepts each request sent to the WFServlet and copies the names of the parameters in the request into a new multi-valued PARAMS variable which you can then access from within your focexec.

The following useful document describes how tomcat filters work:

http://www-106.ibm.com/developerworks/java/library/j-to...t=grj,p=TomcatTricks

You'll want to read the above document to determine how best to configure your tomcat. The following is a sample java filter that creates a "PARAMS" multi-valued parameter. You will probably want to revise this code to work properly at your site. If you find any bugs, please let me know.

// ParamFilter - This class defines a Tomcat Servlet 2.3 Filter
//
// NOTE: This filter will add the PARAMS parameter array to the request.
// ------------------------------------------------------------------------
// 09/29/2004 James Muir Initial coding.
// ------------------------------------------------------------------------
package org.hitchcock.dhdrs.filters;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public final class ParamFilter implements Filter
{
// Data.

private FilterConfig config = null;

// Public Methods.

// init: initialize the filter.
// ------------------------------------------------------------------
public void init (FilterConfig c)
{
this.config = c;
}

// destroy: destroy the filter.
// ------------------------------------------------------------------
public void destroy ()
{
this.config = null;
}

// doFilter: let's do some filtering. We create a subclass of the
// HttpServletRequestWrapper that overrides the getParameter() method
// and it's other friends. Here we create an instance of our custom
// wrapper that wraps the request we originally received. Then we call
// chain.doFilter to pass the wrapper instance instead of the original
// request.
// ------------------------------------------------------------------
public void doFilter (ServletRequest req, ServletResponse res,
FilterChain chain) throws ServletException, IOException
{
ParamRequestWrapper wrapper =
new ParamRequestWrapper((HttpServletRequest)req);

chain.doFilter(wrapper,res);
}


public final class ParamRequestWrapper extends HttpServletRequestWrapper
{
// Data.

private HashMap params = null;

// Constructor.

ParamRequestWrapper (HttpServletRequest req)
{
super(req);

this.params = _setParams((HashMap)req.getParameterMap());
}


// Methods.

// getParameter: returns the value of a request parameter as a String,
// or null if the parameter does not exist. For HTTP servlets,
// parameters are contained in the query string or posted form data.
//
// You should only use this method when you are sure the parameter
// has only one value. If the parameter might have more than one value,
// use getParameterValues(java.lang.String).
//
// If you use this method with a multivalued parameter, the value
// returned is equal to the first value in the array returned by
// getParameterValues.
// ------------------------------------------------------------------

public String getParameter (String name)
{
String[] v = (String[])this.params.get(name);

return (v == null) ? null : v[0];
}


// getParameterNames: returns an Enumeration of String objects
// containing the names of the parameters contained in this request.
// If the request has no parameters, the method returns an empty
// Enumeration.
// ------------------------------------------------------------------

public Enumeration getParameterNames()
{
Vector v = new Vector (this.params.keySet());

return v.elements();
}


// getParameterValues: returns an array of String objects containing
// all of the values the given request parameter has, or null if the
// parameter does not exist. If the parameter has a single value, the
// array has a length of 1.
// ------------------------------------------------------------------

public String[] getParameterValues(String name)
{
return (String[])this.params.get(name);
}


// getParameterMap: returns an immutable java.util.Map containing
// parameter names as keys and parameter values as map values. The
// keys in the parameter map are of type String. The values in the
// parameter map are of type String array.
// ------------------------------------------------------------------

public Map getParameterMap()
{
return (Map)this.params;
}


// _setParams: create a parameters HashMap. The keys in the map are
// of type String. The values in the map are of type String array.
// ------------------------------------------------------------------
private HashMap _setParams(HashMap p)
{
int i = 1;

HashMap map = new HashMap();

map.putAll(p);

Iterator it = p.keySet().iterator();

while(it.hasNext())
{
String key = "PARAMS" + String.valueOf(i++);

_putString( map, key, (String)it.next());
}

_putString( map, "PARAMS0", String.valueOf(i-1));

return map;
}


// _putString: Add an entry to a hash map that has a String as key,
// and a string array with one element as value.
// ------------------------------------------------------------------
private void _putString(HashMap map, String key, String value)
{
String array[] = new String[1];

array[0] = value;

map.put(key, array);
}
}
}


And the following is a sample focexec that displays the parameters sent it using the &PARAMS variable:


-* Echo parameters in form.
-*
-SET &LIMIT = &PARAMS0;
-REPEAT LOOP FOR &COUNTER FROM 1 TO &LIMIT STEP 1
-SET &MYPARM1 = 'PARAMS' | &COUNTER;
-SET &MYPARM2 = '&' || &MYPARM1;
-SET &MYPARM3 = '&' || &MYPARM2.EVAL;
-IF &MYPARM3.EVAL.EXISTS EQ 0 THEN GOTO NULLVALUE;
-TYPE &MYPARM1.EVAL: NAME=&MYPARM2.EVAL VALUE=&MYPARM3.EVAL
-GOTO NEXT
-NULLVALUE
-TYPE &MYPARM1.EVAL: NAME=&MYPARM2.EVAL VALUE=NULL
-GOTO NEXT
-NEXT
-LOOP
-EXIT
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Displaying ALL Parameters

Copyright © 1996-2020 Information Builders