For users of the BIRT web viewer prior to 2.2, there is an annoying issue if you used an external form page to call reports. If you used a POST method instead of a GET method, the parameters are completely ignored. This issue has since been corrected in the 2.2 M4 and M5 releases of BIRT, but for you folks who still run the older version I have a fix for you.
Some time ago I was asked to look into this as an issue for a client. After digging into the source code, I found what the problem was. While technically speaking, parameters are read the same from the GET and POST methods in the BIRT web viewer, the problem comes when the web viewer makes the SOAP call to the report engine. Parameter values are not retained during a recall of the application because the URL changes, so parameters are not passed back. Below is a patch to the BIRT source tree (2.1.1 stable) that will fix the issue by making patches to the appropriate source files in the BIRT web viewer source.
What this does is create a session parameter called SoapURL, inside of the BirtSoapDispatcher class. It then builds a special URL with all the parameters for all SOAP calls to use the already existing GET handler. It then patches all the JavaScript files to use this new URL instead of the document location.
This is a very simple fix, and storing the parameters in anything more complicated would require more complex modification off the BIRT web viewer source.
To apply this patch, you will need to get the BIRT source code from either CVS or from a archive somewhere. Apply the patch as needed (I used Eclipses DIFF utility to create this patch). Now, external forms will be able to use either GET or POST methods to pass parameters to the BIRT web viewer.
Index: org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js,v
retrieving revision 1.6
diff -u -r1.6 AbstractBaseToc.js
--- org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js 18 Aug 2006 06:00:16 -0000 1.6
+++ org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js 23 Dec 2006 03:39:46 -0000
@@ -259,7 +259,7 @@
*/
__neh_click_broadcast : function( query, realId )
{
- birtSoapRequest.setURL( document.location );
+ birtSoapRequest.setURL( soapURL );
if( query == '0' )
{
birtSoapRequest.addOperation( Constants.documentId, Constants.Document,
@@ -369,7 +369,7 @@
if( root.query != 1 )
{
root.query = '1';
- birtSoapRequest.setURL( document.location );
+ birtSoapRequest.setURL( soapURL );
birtSoapRequest.addOperation( Constants.documentId, Constants.Document, "GetToc", null );
return true;
}
Index: org.eclipse.birt.report.viewer/birt/webcontent/birt/pages/layout/FramesetFragment.jsp
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.viewer/birt/webcontent/birt/pages/layout/FramesetFragment.jsp,v
retrieving revision 1.11
diff -u -r1.11 FramesetFragment.jsp
--- org.eclipse.birt.report.viewer/birt/webcontent/birt/pages/layout/FramesetFragment.jsp 25 Jul 2006 05:41:14 -0000 1.11
+++ org.eclipse.birt.report.viewer/birt/webcontent/birt/pages/layout/FramesetFragment.jsp 23 Dec 2006 03:39:47 -0000
@@ -35,6 +35,18 @@
<LINK REL="stylesheet" HREF="birt/styles/style.css" TYPE="text/css">
<link href="birt/styles/dialogbase.css" media="screen" rel="stylesheet" type="text/css"/>
+ <script type="text/javascript">
+ var soapURL =
+ <%
+ if (request.getAttribute("SoapURL") != null)
+ {
+ out.print("\"" + request.getAttribute("SoapURL").toString() + "\"");
+ }
+ else {
+ out.print("document.location");
+ } %>;
+ </script>
+
<script src="birt/ajax/utility/Debug.js" type="text/javascript"></script>
<script src="birt/ajax/lib/prototype.js" type="text/javascript"></script>
Index: org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js,v
retrieving revision 1.9
diff -u -r1.9 BirtReportDocument.js
--- org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js 5 Jun 2006 09:27:23 -0000 1.9
+++ org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js 23 Dec 2006 03:39:47 -0000
@@ -69,7 +69,7 @@
}
birtSoapRequest.addOperation( Constants.documentId, Constants.Document,
"CacheParameter", null, birtParameterDialog.__parameter );
- birtSoapRequest.setURL( document.location );
+ birtSoapRequest.setURL( soapURL );
birtEventDispatcher.setFocusId( null ); // Clear out current focusid.
return true;
},
Index: org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js,v
retrieving revision 1.1
diff -u -r1.1 AbstractBaseReportDocument.js
--- org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js 28 Apr 2006 05:26:32 -0000 1.1
+++ org.eclipse.birt.report.viewer/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js 23 Dec 2006 03:39:46 -0000
@@ -95,7 +95,7 @@
birtSoapRequest.addOperation( Constants.documentId, Constants.Document,
"ChangeParameter", null, birtParameterDialog.__parameter,
{ name : "svg", value : this.__has_svg_support? "true" : "false" } );
- birtSoapRequest.setURL( document.location );
+ birtSoapRequest.setURL( soapURL );
birtEventDispatcher.setFocusId( null ); // Clear out current focusid.
return true;
},
@@ -106,7 +106,7 @@
__beh_cascadingParameter : function( id, object )
{
birtSoapRequest.addOperation( Constants.documentId, Constants.Document, "GetCascadingParameter", null, object );
- birtSoapRequest.setURL( document.location );
+ birtSoapRequest.setURL( soapURL );
birtEventDispatcher.setFocusId( null ); // Clear out current focusid.
return true;
},
@@ -131,7 +131,7 @@
*/
__beh_getPage : function( id, object )
{
- birtSoapRequest.setURL( document.location );
+ birtSoapRequest.setURL( soapURL );
if ( object )
{
birtSoapRequest.addOperation( Constants.documentId, Constants.Document,
@@ -158,7 +158,7 @@
*/
__beh_export : function( id )
{
- birtSoapRequest.setURL( document.location);
+ birtSoapRequest.setURL( soapURL);
birtSoapRequest.addOperation( "Document", Constants.Document, "QueryExport", null );
return true;
}
Index: org.eclipse.birt.report.viewer/birt/WEB-INF/classes/org/eclipse/birt/report/servlet/BirtSoapMessageDispatcherServlet.java
===================================================================
RCS file: /cvsroot/birt/source/org.eclipse.birt.report.viewer/birt/WEB-INF/classes/org/eclipse/birt/report/servlet/BirtSoapMessageDispatcherServlet.java,v
retrieving revision 1.6
diff -u -r1.6 BirtSoapMessageDispatcherServlet.java
--- org.eclipse.birt.report.viewer/birt/WEB-INF/classes/org/eclipse/birt/report/servlet/BirtSoapMessageDispatcherServlet.java 25 Jul 2006 05:43:33 -0000 1.6
+++ org.eclipse.birt.report.viewer/birt/WEB-INF/classes/org/eclipse/birt/report/servlet/BirtSoapMessageDispatcherServlet.java 23 Dec 2006 03:39:46 -0000
@@ -146,6 +146,17 @@
return;
}
+ java.lang.StringBuilder builder = new java.lang.StringBuilder();
+ for (java.util.Iterator it = request.getParameterMap().keySet().iterator(); it.hasNext();)
+ {
+ String paramName = it.next().toString();
+ String paramValue = request.getParameter(paramName);
+ builder.append("&" + paramName + "=" + paramValue);
+ }
+ String soapURL = request.getRequestURL().toString() + "?" + request.getQueryString() + builder.toString();
+
+ request.setAttribute("SoapURL", soapURL);
+
IContext context = __getContext( request, response );
try