ActiveReports 6 Support

Started by JoshTitley at 03-08-2010 9:56 PM. Topic has 10 replies.

Print Search Rate
Sort Posts:    
   03-08-2010, 9:56 PM
JoshTitley is not online. Last active: 6/9/2010 1:56:35 PM JoshTitley

Not Ranked
Joined on 03-09-2010
Posts 3
Problems With Active Reports 6 FlashViewer and UseClientApi
Normal 0 false false false MicrosoftInternetExplorer4










I just thought I'd post some information about the recent UseClientApi feature in the Active Reports 6 Flash Viewer.  I wanted to put hyperlink buttons in the top in order to have Export to PDF and to Export to Excel.  It would seem that there are a few issues getting it to work correctly.   I thought I'd share some workarounds.


I initially added the buttons in code like so:

customButton = Tool.CreateButton("PDF");

                customButton.Caption = "PDF";

                customButton.ToolTip = "Click here to export to PDF";

                customButton.ClickNavigateTo = "FlashViewer.aspx?Export=PDF";

                WebViewer.FlashViewerToolBar.Tools.Add(customButton);

 

But I didn’t like it how in IE 7 it pop’s up in a new tab.  So I wanted to use the new UseClientApi feature to make a clean download on the viewer page.


Firstly, I couldn't get the UseClientApi feature to fire events.  It would seem that the Javascript for this is only injected into the aspx page if there is a webform.  So you have to have a form even if you don't plan on using one.  The Flash Viewer doesn't have to be placed inside the form, but so long as there is a form on your page, Active Reports will inject the proper Javascript.


     <ActiveReportsWeb:WebViewer ID="WebViewer" runat="server"

        ViewerType="FlashViewer" Width="100%" Height="100%" >       

        <FlashViewerOptions UseClientApi="true" />

     </ActiveReportsWeb:WebViewer>

 

<form id="form1" runat="server">    

</form>

 

The documentation mentions attaching, and pasting code into your page, but it doesn't give the specifics.  So what I did was create an onload event for the body like so:

 

<body onload = "window_onload();">

 

and then created a javascript snippet in the head tag:

 

 

 

<script type="text/javascript">

    //<![CDATA[

    function window_onload() {

        var viewer;

        viewer = DataDynamics.ActiveReport.Viewer.Attach(”WebViewer”);

    }       

    //]]>

</script>

 

With this in place you will find that the viewer object is set correctly.

 

At this point, everything worked for Firefox, but when I tried IE7 I ran into trouble.  For some reason the injected Javascript was throwing errors.  I wasn’t able to find out why, but I was able to work around the problem.  If an error is thrown I catch it and then try to set the viewer object to the correct instant.  Note that this workaround will only work if you have one viewer on your page.  If you have multiple viewers, all events will be sent to the one object and you will probably have to do some fancy coding to determine which viewer to use.

 

var viewer;

        try

        {

            viewer = DataDynamics.ActiveReport.Viewer.Attach("WebViewer");

        }

        catch (error)

        {                    

            var obj;

            if (document.all) obj = document.all["WebViewer_fvo"];

            else if (document.getElementById) obj = document.getElementById(objid);

 

            DataDynamicsActiveReportMap[""] = obj;

            viewer = obj;

         }

 

Here is the complete code.  Note that you will still need to make sure you have ClickNavigateTo set on your buttons in your code.  If you don’t the Javascript events won’t be raised.

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FlashViewer.aspx.cs" Inherits="AvonBusinessAnalytics.FlashViewer" %>

 

<%@ Register TagPrefix="ActiveReportsWeb" Namespace="DataDynamics.ActiveReports.Web"

    Assembly="ActiveReports.Web, Version=6.0.2250.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>ActiveReports 6 Flash WebViewer</title>

    <style type="text/css">

    html, body, #WebViewer, #WebViewer_controlDiv

    {

        width: 100%;

        height: 100%;

        margin: 0;

    }

    </style>

<script type="text/javascript">

    //<![CDATA[

 

    function window_onload() {

        var viewer;

        try

        {

            viewer = DataDynamics.ActiveReport.Viewer.Attach("WebViewer");

        }

        catch (error)

        {       

            // There seems to be some bugs with FlashViewer and IE! When the viewer is shown

            // a second time, we get errors.  Don't know why this happens.  The cause is that

            // an ID is blank. Since we only have one viewer on a page, not a problem.

            // We will just default the dodgy blank ID with the correct object so events

            // will be handled correctly

            var obj;

            if (document.all) obj = document.all["WebViewer_fvo"];

            else if (document.getElementById) obj = document.getElementById(objid);

 

            DataDynamicsActiveReportMap[""] = obj;

            viewer = obj;

         }

 

        viewer.setEventsHandler({

            OnToolClick: function(e) {

                if ((e.Tool == "Back") || (e.Tool == "Return"))

                    history.back();

                else

                    window.location = "FlashViewer.aspx?Export=" + e.Tool;

                return true;

            }

        });

    }       

//]]>

</script>

</head>

<body onload = "window_onload();">        

<!-- // Workaround: Took me 2 hours! FlashViewer for some reason needs a form before ClientApi

     works! . -->   

     <ActiveReportsWeb:WebViewer ID="WebViewer" runat="server"

        ViewerType="FlashViewer" Width="100%" Height="100%" >       

        <FlashViewerOptions UseClientApi="true" />

     </ActiveReportsWeb:WebViewer>

 

<form id="form1" runat="server">    

</form>   

</body>

</html>

 

And my buttons look like this:


                WebViewer.Report = report;

 

                ToolButton customButton = Tool.CreateButton("Return");

                customButton.Caption = "Return";

                customButton.ToolTip = "Click here to return to report options";

                customButton.ClickNavigateTo = "BLOCKED SCRIPThistory:back();";

                WebViewer.FlashViewerToolBar.Tools.Add(customButton);

               

                customButton = Tool.CreateButton("PDF");

                customButton.Caption = "PDF";

                customButton.ToolTip = "Click here to export to PDF";

                customButton.ClickNavigateTo = "FlashViewer.aspx?Export=PDF";

                WebViewer.FlashViewerToolBar.Tools.Add(customButton);

 

                customButton = Tool.CreateButton("EXCEL");

                customButton.Caption = "EXCEL";

                customButton.ToolTip = "Click here to export to Excel";

                customButton.ClickNavigateTo = "FlashViewer.aspx?Export=EXCEL";

                WebViewer.FlashViewerToolBar.Tools.Add(customButton);

 

                customButton = Tool.CreateButton("WORD");

                customButton.Caption = "WORD";

                customButton.ToolTip = "Click here to export to Word";

                customButton.ClickNavigateTo = "FlashViewer.aspx?Export=WORD";

                WebViewer.FlashViewerToolBar.Tools.Add(customButton);

 

                customButton = Tool.CreateButton("TEXT");

                customButton.Caption = "TEXT";

                customButton.ToolTip = "Click here to export to Text";

                customButton.ClickNavigateTo = "FlashViewer.aspx?Export=TEXT";

                WebViewer.FlashViewerToolBar.Tools.Add(customButton);
   Report 
   03-09-2010, 12:35 PM
SankalpS is not online. Last active: 1/19/2012 9:03:40 AM SankalpS

Top 10 Posts
Joined on 12-11-2008
Posts 2,414

DDStaff
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
JoshTitley,

Thank you for taking out time to write this code and sharing your observations with us. I am sure other users will benefit from the information provided by you.

Regards,
Sankalp
Sankalp Sen
GrapeCity- DataDynamics
   Report 
   03-10-2010, 12:51 AM
SergeyR is not online. Last active: 1/25/2012 12:42:59 PM SergeyR

Top 10 Posts
Joined on 02-02-2005
Posts 2,052

DDStaff
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
Hello ,

The issue with ClickNavigateTo property was fixed (Case 140061)
In the next release of product, OnToolClick event will fire even through ClickNavigateTo property is empty.

Thanks,
Sergey Romanov.
   Report 
   03-10-2010, 2:23 AM
Pavlov Konstantin is not online. Last active: 3/10/2010 4:06:39 PM Pavlov Konstantin

Not Ranked
Joined on 07-16-2009
Posts 14
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
Hello, JoshTitley

I have seen the same problem with FlashViewer and IE7 on my ASP.NET Development server,
it looks like: "Microsoft JScript runtime error: Object doesn't support this property or method" at obj.setId(objid);
but when I have deployed application on IIS and configured all AR handlers this problem has been fixed.
   Report 
   03-10-2010, 3:57 AM
Pavlov Konstantin is not online. Last active: 3/10/2010 4:06:39 PM Pavlov Konstantin

Not Ranked
Joined on 07-16-2009
Posts 14
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
Josh, am I correctly understand, that you have mistake at "OnToolClick" event handler? You should set "return false;" if you wanted to handle such JS event.
   Report 
   03-10-2010, 4:06 PM
JoshTitley is not online. Last active: 6/9/2010 1:56:35 PM JoshTitley

Not Ranked
Joined on 03-09-2010
Posts 3
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
" Microsoft JScript runtime error: Object doesn't support this property or method" at obj.setId(objid)
was the error that I was getting and the Javascript was how I got around this issue.  Funnily enough it doesn't occur during development and only when deployed on IIS.  All AR handlers are installed correctly.  Is there a specific handler that might be causing this issue?


   Report 
   03-10-2010, 10:48 PM
Pavlov Konstantin is not online. Last active: 3/10/2010 4:06:39 PM Pavlov Konstantin

Not Ranked
Joined on 07-16-2009
Posts 14
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
I have not seen any specific handler:
*.ActiveReport
*.ArCacheItem
*.rpx
   Report 
   03-11-2010, 7:08 AM
AashishB is not online. Last active: 12/24/2010 3:51:14 PM AashishB

Top 25 Posts
Joined on 12-11-2008
Posts 818
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
JoshTitley,

Please make sure that you enable HTTP handlers from the web.config file as described in this link. The IIS 7 handler configuration should be similar to this KB article.

Regards,
Aashish

   Report 
   03-11-2010, 10:29 PM
konstantins is not online. Last active: 3/12/2010 11:59:29 AM konstantins

Not Ranked
Joined on 03-30-2009
Posts 10
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
 JoshTitley wrote:
" Microsoft JScript runtime error: Object doesn't support this property or method" at obj.setId(objid)
was the error that I was getting and the Javascript was how I got around this issue.  Funnily enough it doesn't occur during development and only when deployed on IIS.  All AR handlers are installed correctly.  Is there a specific handler that might be causing this issue?


Hello.

First of all, we created this setId method to separate different FV on same page. And this method is introduced as JS method through flex's ExternalInterface. So, most likely, flash object is not initialized yet on 'body' 'onload' event.

Possible workarounds I see are the following:
1. Use timer to call 'Attach' method each 10 ms (for example), and if no exception occurs, stop timer and use found object
2. Try to use other JS events to find FV object
3. Best solution I can think of is to slightly extend client API: FV will invoke JS function with predefined name after its initialization is finished. And if client has defined JS function with such name, it will be invoked. In this scenario, everything should be fine with object initialization.
4. I will request QA or support team to create case, related to this issue, because it looks like it is common issue with ExternalInterface and IE, and there are several solutions.

Based on mentioned things, I highly doubt that any handler can cause such behavior.


   Report 
   03-24-2010, 11:00 PM
oleg.zaimkin is not online. Last active: 3/22/2010 11:29:08 AM oleg.zaimkin

Top 200 Posts
Joined on 04-01-2009
Posts 49

DDStaff
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
JoshTitley,

obviously body.onload (also DOMContentLoad and such) is not a proper place to call Flash object because it's not completely initialized at that time.
We are going to add OnLoad method which will allow perform proper initialization of FlashViewer control. Consider using the following JavaScript code as a temporary workaround:

function onLoad(id, fn) {
var isAlive = function() {var obj = swfobject.getObjectById(id + '_fvo'); return (obj && obj.setZoom) ? true: false;};

if(isAlive()) {fn();}
else {
var retryIntervalId = null;
var checkAlive = function() { if(isAlive()) {clearInterval(retryIntervalId); fn();}};
retryIntervalId = setInterval(checkAlive, 100);
}
}

Here's the example of using it from your ASPX page:
OnLoad("WebViewer1", function() {
window.viewerApp = DataDynamics.ActiveReport.Viewer.Attach("WebViewer1");
window.viewerApp.setTocPanelVisible(true);
});


Regarding "It would seem that the Javascript for this is only injected into the aspx page if there is a webform" it looks like fundamental requirement for WebForms and particularly for RegisterScriptBlock API methods.

   Report 
   06-09-2010, 11:25 PM
JoshTitley is not online. Last active: 6/9/2010 1:56:35 PM JoshTitley

Not Ranked
Joined on 03-09-2010
Posts 3
Re: Problems With Active Reports 6 FlashViewer and UseClientApi
Oleg,

Thank you for the response. I only got around to trying your work around now and it fixes the problem.

- Josh
   Report 
GrapeCity » Product Support » ActiveReports 6... » Problems With Active Reports 6 FlashViewer and UseClientApi

Privacy Policy | Copyright © 1997-2012 — GrapeCity, inc.
All trademarks mentioned are the property of their respective owners.