Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Viewing a report with parameters by calling WebViewer.display()
SergeD
I'm using the WebViewer.display() method to generate a report with from an RCP application. How can I define the parameters from the application without let them enter by the user in the WebViewer ?
I must use the WebWiever because the other solution to generate a report start a separated OSGi platform.
Could you help me please ?
Find more posts tagged with
Comments
JasonW
You could build your own createURL function and instead of calling display set the url for your browser like:
//Use the TopNPercent.rptdesign with this example
WebViewer.startup();
String format = "html";
String preParameters = createURL( "frameset", reportName, format );
//Make sure to encode your parameters
String parm1NameString = URLEncoder.encode( "Top Count", "utf-8" );
String parm1ValueString = URLEncoder.encode( "5", "utf-8" );
String parm2NameString = URLEncoder.encode( "Top Percentage", "utf-8" );
String parm2ValueString = URLEncoder.encode( "25", "utf-8" );
String finalUrl = preParameters + "&" + parm1NameString + "=" + parm1ValueString;
finalUrl += "&" + parm2NameString + "=" + parm2ValueString;
browser.setUrl( finalUrl );
private static String createURL( String servletName, String report, String format )
{
String encodedReportName = null;
String encodedDocumentName = null;
try
{
encodedReportName = URLEncoder.encode( report, "utf-8" );
}
catch ( UnsupportedEncodingException e )
{
// Do nothing
}
if ( encodedReportName != null && encodedReportName.length( ) > 0 )
{
encodedDocumentName = encodedReportName.substring( 0, encodedReportName.lastIndexOf( "." ) ) + ".rptdocument";
}
String locale = ViewerPlugin.getDefault( ).getPluginPreferences( ).getString( WebViewer.USER_LOCALE );
String svgFlag = ViewerPlugin.getDefault( ).getPluginPreferences( ).getString( WebViewer.SVG_FLAG );
boolean bSVGFlag = false;
if ( "true".equalsIgnoreCase( svgFlag ) ) //$NON-NLS-1$
{
bSVGFlag = true;
}
String masterPageContent = ViewerPlugin.getDefault( ).getPluginPreferences( ).getString( WebViewer.MASTER_PAGE_CONTENT );
boolean bMasterPageContent = true;
if ( "false".equalsIgnoreCase( masterPageContent ) )
{
bMasterPageContent = false;
}
// So far, only report name is encoded as utf-8 format
return getBaseURL( )+ servletName + "?" + "__report=" + encodedReportName + ( "run".equalsIgnoreCase( servletName )? "" : "&__document=" + encodedDocumentName ) + "&__format=" + format + "&__svg=" + String.valueOf( bSVGFlag )
+ ( WebViewer.LocaleTable.containsKey( locale )? "&__locale=" + WebViewer.LocaleTable.get( locale ) : "" ) "&__designer=true" + "&__masterpage=" + String.valueOf( bMasterPageContent );
}
private static String getBaseURL( )
{
return "
http://"
; + WebappAccessor.getHost( ) + ":" + WebappAccessor.getPort("viewer" ) + "/viewer/";
}