EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
Expand all | Collapse all

Rich UI open new windows

  • 1.  Rich UI open new windows

    Posted Thu April 29, 2010 07:43 AM

    Hi,
    I have created a Rich UI that generates Birt reports using a web service. Now, of course, I want to show these reports in my browser. I tried what Chris described in "How to popup a PDF" http://www.ibm.com/developerworks/mydeveloperworks/blogs/3e2b35ae-d3b1-4008-adee-2b31d4be5c92/entry/how_to_pop_up_a_pdf?lang=en but I cant make it work. It does not open a new window or shows me the " Save" dialog.

    Then i tried to use the document.location = "http://www.redbooks.ibm.com/redpapers/pdfs/redp4638.pdf"; which actually opens the PDF, and thats fine. But what i want is to open it in a new window. How do i open new Browser windows instead of opening in the same window?

    Edited by: markevans on Aug 20, 2010 4:01 PM
    SystemAdmin


  • 2.  Re: Rich UI open new windows

    Posted Thu April 29, 2010 10:17 AM
    This isn't exactly what you are looking for - but when I did BIRT html reports with RichUI. I published the birt.war to my server and then let it host the reports itself. That way whenever I wanted to show them from RichUI I could just provide a boring old html link to the birt.war application.

    This link describes my setup
    http://www.ibm.com/developerworks/forums/thread.jspa?threadID=337859&tstart=525

    The link I build in EGL was something like

    reportLink HTML{text="myReport"};

    This (TARGET="_blank") took it into a new window for me. Unfortunately you can't control whether its a new window or a tab as thats a browser preference. Perhaps a similar strategy can be used for the pdf?

    Aaron Allsbrook
    ClearBlade

    Edited by: mevans_admin on Aug 20, 2010 4:00 PM

    Edited by: markevans on Aug 20, 2010 4:01 PM
    SystemAdmin


  • 3.  Re: Rich UI open new windows

    Posted Mon May 03, 2010 07:42 AM

    Thanks a lot for your reply. This could end out being the solution to my problem.

    But I really would like to just be able to open up a new window using Rich UI. And it doesn't matter if its in a tab as you said.
    SystemAdmin


  • 4.  Re: Rich UI open new windows

    Posted Mon May 03, 2010 12:23 PM
    We use the Birt report viewer deployed to Tomcat. Then, from our applications, we "launch" a new browser window with a URL to show a particular (user-selected) report.

    As far as launching a new window goes, here's the external type def and JavaScript for the external type:

    com.mypackage.customer.widgets.Launch.egl
    externalType Launch extends Widget type JavaScriptObject {
    relativePath = "com/mypackage/custom/widgets",
    javaScriptName = "Launch"
    }

    function openWindow(host string in, reportPath string in) returns(boolean);

    end


    WebContent/com/mypackage/customer/widgets/Launch.js
    egl.defineClass(
    'com.mypackage.custom.widgets', 'Launch',
    {
    "constructor" : function()
    { },

    "openWindow" : function (host, reportPath) {
    var d = new Date();
    var t_min = d.getMinutes(); // Returns minutes
    var t_sec = d.getSeconds(); // Returns seconds
    var t_mil = d.getMilliseconds(); // Returns Milliseconds
    var winName='appWindow'+t_min+t_sec+t_mil;
    var windowUrl=host+escape(reportPath);
    m = window.open(windowUrl,winName,'resizable=yes');

    return true;
    }
    });


    Then, from a Rich UI handler or widget:
    launch Launch {};
    launch.openWindow(host, reportPath);


    Our "host" variable is something like "http://www.xxxxxxxxxxxxxx.com:8081/birt/frameset?__report=/" (using the protocol, server, and port where we host the Birt report viewer). And, for us, a "reportPath" variable looks something like "AlInvoices.rptdesign".

    Note: The Birt viewer requires configuration to be able to find the report designs that are pre-deployed to the server. This is described in the Birt documentation.

    Hope this helps.

    --Dan

    p.s. We use a nearly identical technique to serve up PDF's and other document types by substituting a different "host" and "reportPath"....a host and report path not related to Birt.
    dan_darnell


  • 5.  Re: Rich UI open new windows

    Posted Mon August 09, 2010 04:26 AM
    Great! Thanks a lot...
    SystemAdmin


  • 6.  Re: Rich UI open new windows

    Posted Thu June 23, 2011 12:59 PM
    Hi Dan,

    Thank you for the launch javascript. I used it to serve and open pdf documents in a new window. The pdf documents are dynamically generated on iSeries IFS folders. I use the file protocal, thus the winURL passed to the launch function is something like "file://///blahblahblah.com/tmp/tr/00077201.pdf".

    This opens a new window in IE and the pdf is shown. However, the window won't open in Firefox. In Chrome, in open a blank page. There must be some tricks to it.

    Thank in advance.
    Howard
    SystemAdmin


  • 7.  Re: Rich UI open new windows

    Posted Thu June 23, 2011 01:26 PM
    Do you have a PDF viewer (installed plug-in) that you are using for Firefox and/or Chrome? If you just paste the file URL into the Firefox and/or Chrome address bar (outside of your application altogether) does the PDF show up?

    We experimented with file system URL's but found them problematic (necessity for mapped drive and other issues) so we serve all files to browser-based apps via an Apache HTTP server instance. Makes life much easier, even for internal consumption of documents.

    --Dan
    dan_darnell


  • 8.  Re: Rich UI open new windows

    Posted Thu June 23, 2011 02:25 PM
    Hi Dan,

    Thanks. If I paste the url "file://///zzz.com/...pdf" on to firefox and Chrome, the pdf file shows up. And yes I would rather serve the files in an "Apache HTTP server instance" and would like to have more details on it.

    Would I then need to "launch" a iFrame page in a new window to open the pdf file ?
    Thanks again,
    Howard
    SystemAdmin


  • 9.  Re: Rich UI open new windows

    Posted Thu June 23, 2011 02:45 PM
    Hi Howard,

    Yes, using Apache we launch an iframe to open a PDF file. From an EGL point of view, we do something like this:

    ui Div { children=[documentLink] };documentLink HTML {  };fileName string = "myfile.pdf"; urlText string = "<iframe src=\""+     Properties.imageServer + "\\reports\\" +     servicelib.convertToURLEncoded(clip(fileName)) +     "\" "+ "width=100% height=" + ui.height +     " frameborder=0>/iframe>";  documentLink.text=urlText;


    "Properties.imageServer" is a reference to an Apache instance ("http:\\server:port").

    Apache configuration is a large topic until itself but one way to approach it is with Directory and Alias:

    Alias /reports "/tempReports"                                                                       <Directory "/tempReports">                           Order Allow,Deny                                  Allow From all                                 </Directory>


    This is the simplest case, with no security, etc.

    --Dan
    dan_darnell


  • 10.  Re: Rich UI open new windows

    Posted Fri June 24, 2011 10:07 AM
    Hi Dan,

    This is great !!! Thanks again.

    Howard
    SystemAdmin


  • 11.  Re: Rich UI open new windows

    Posted Fri June 24, 2011 07:54 PM
    Actually, the EGL code I posted is from a place where we embed PDF documents in an EGL application. To open a PDF document in a new window from EGL I think you would just "launch" it (no iframe required):

    host string = "http://www.xxxxxxxxxxx.com";reportPath = "/reports/mypdf.pdf"; launch Launch {};launch.openWindow(host, reportPath);


    The browser will take care of it from there as long as a PDF plug-in is present.
    dan_darnell


  • 12.  Re: Rich UI open new windows

    Posted Mon June 27, 2011 04:04 PM
    Hi Dan,

    Thanks for your help again.

    Everything works nicely from the iSeries now. This is our second EGL web 2.0 project to go live this year. Backend processes are EGL dedicated web-services (and all written in RPGLE), except some local calculations (like date/time and simple math we would do inside EGL). All program logic are in RPGLE and some of the codes were copied out from existing programs (or made into MODs for reusable).

    RBD 8 is so wonderful and EGL Web 2.0 apps can also be integrated with existing 5250 apps, Our new online programs will mostly be written in EGL from now on. (Users fell in love with RUI, they didn't feel big deal about JSF though ;-)

    Thanks again,
    Howard
    SystemAdmin


  • 13.  Re: Rich UI open new windows

    Posted Wed July 22, 2015 04:33 PM

    Awesome!

     

    Thank you so much Dan; works perfectly.

     

    Walt Grace

     

    Walt1968