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

Run a dos command

Discussion Topic

Discussion TopicMon March 09, 2015 05:36 AM

  • 1.  Run a dos command

    Posted Wed March 04, 2015 10:23 AM

    Hi

    is it possibile run a dos command (from Rich ui Handler) , when the user click on a button ?

    If yes, could some supply an example

    Thanks in advance

     

    giocot


  • 2.  Re: Run a dos command

    Posted Wed March 04, 2015 12:32 PM

    I don't know of any way to do this with plain EGL.

    I don't think you should either. Rui is web technology, which is (mostly) platform independent. If your client runs your rui application on anything other than windows the command would not work.

    There are also some security issues with what you want to accomplish. I think most browsers will complain.

     

    That being said, it should be possible with javascript, using IE's Active X wrapped as an externaltype.

        var char34 = String.fromCharCode(34);    var wsh = new ActiveXObject('WScript.Shell');    if (wsh)    {        command = 'cmd /k ' + char34 + wsh.ExpandEnvironmentStrings(command) + ' ';        command = command + char34 + wsh.ExpandEnvironmentStrings(option) + char34  + char34;        if (confirm(command))        {            wsh.Run(command);        }    }

    I have not tried it myself and I don't recommend it.

     

    Bram

    Bram_Callewaert


  • 3.  Re: Run a dos command

    Posted Wed March 04, 2015 01:03 PM

    Hi Bram

    Thanks for you reply;

    this my need/idea: i'm try to following the tutorial "Create a mortgage application with EGL Rich UI"  and the example , shows an application like Portal; my idea is to open/display in this "portal",  also a 5250 session to connect to iSeries ..  it is an impossible request ?

    Thanks in advance

    giocot


  • 4.  Re: Run a dos command

    Posted Thu March 05, 2015 02:46 AM

    I don't think it is impossible, but it is certainly not best practice.

    It would be cleaner to get "I access for web" set up (5250 emulation in the browser), and have a "portal" to this web application.

    This would work cross-browser and cross-system.

    Bram_Callewaert


  • 5.  Re: Run a dos command

    Posted Thu March 05, 2015 03:38 AM

    Hi Bram

    thanks again for your reply, sorry but for me this  (Egl and Web) is a new world.  I make you this question:  starting from the "utils.portal" that i find inside "com.ibm.egl.rui.dojo.samples_2.1.3", do you thing could possible insert a button (like Add1 or Add2 etc etc)  that open 5250 emulation ?

    Thanks in advance

    attached the PortalSample image as i would like to have

    giocot

    Attachments



  • 6.  Re: Run a dos command

    Posted Thu March 05, 2015 07:59 AM

    Hi,

    I agree with Bram in that it would seem to be a better solution to use a technology that allows you to open a 5250 session in the browser.

    Here is a link to the one that Bram listed. 

    http://www-03.ibm.com/systems/power/software/i/access/web.html

    markevans


  • 7.  Re: Run a dos command

    Posted Thu March 05, 2015 08:41 AM

    Hi

    Ok for the Web tecnology to open 5250 session..  (http://www-03.ibm.com/systems/power/software/i/access/web.html)

    but for open/call (see img01)  it from PortalSample how (if possible)  can i do   , once that i have installed the IBM i Acces ?

    Thanks for your help

     

    giocot


  • 8.  Re: Run a dos command

    Posted Fri March 06, 2015 02:59 AM

    I don't know any native way to show a remote site in EGL.

    I have written an externaltype component to load an external site in an iframe.

    I attached the project. Among other things it contains a handler named ExternalSite, which uses a widget RemoteSite to load a remote site.

     

    Popular sites like google, imdb, ... prohibit loading in iframes. This should not be the case for I access for web.

     

    Let me know if you encounter any problems.

     

    Kind regards,

     

    Bram

    Bram_Callewaert


  • 9.  Re: Run a dos command

    Posted Fri March 06, 2015 08:02 AM

    Hi Bram,

    We've had success with iframe in native egl code by using an EGL HTML widget within a Div without having to use an exteraltype.  I realize there are often many ways to the same goal so I offer this as an alternative.

     

    package com.molcy.egl.handlers;import com.ibm.egl.rui.widgets.Box;import com.ibm.egl.rui.widgets.Div;import com.ibm.egl.rui.widgets.GridLayout;import com.ibm.egl.rui.widgets.GridLayoutData;import com.ibm.egl.rui.widgets.HTML;import egl.ui.rui.Event;import dojo.widgets.DojoButton;import dojo.widgets.DojoTextField;handler ExternalSiteNativeRUI type RUIhandler {initialUI = [ ui ],onConstructionFunction = start, cssFile="css/FileUploadRui.css", title="ExternalSiteNativeRUI"}            ui GridLayout{ columns = 1, rows = 2, cellPadding = 4, children = [addressGrid, content] };        addressGrid GridLayout {layoutData = new GridLayoutData{row = 1, column = 1},                                                        columns = 2, rows = 1, cellPadding = 4, children = [urlText, goButton]};        urlText DojoTextField {layoutData = new GridLayoutData {row = 1, column = 1}};                                        goButton DojoButton {layoutData = new GridLayoutData {row = 1, column = 2},                                                 text = "Go",                                                 onClick ::= goButton_onClick};                content Div {layoutData = new GridLayoutData {row = 2, column = 1},                                 width = 1200,                                 height = 750};                function start()        end             private function goButton_onClick (e Event in)                content.removeChildren();                content.appendChild(new HTML{text = "<iframe src = '" + urlText.text                                                                                                + "' width='1090' height='700'></iframe>"}                                                                                                );        endend

     

    canutri


  • 10.  Re: Run a dos command

    Posted Fri March 06, 2015 08:11 AM

    Thanks! Seems like a better way to accomplish this.

    Bram_Callewaert


  • 11.  Re: Run a dos command

    Posted Mon March 09, 2015 04:14 AM

    Hi Bram and Canutri

    Thanks for your reply... very good suggestions  ..

    i would have other  questions;

    1. How can i make Iframe responsive  (see my Img01)
    2. Do you think is possible to display,  at first a fixed size iframe with web page adapted to this size and the with double click expand the iFrame ?  (like RBD Ide when we doubleclick on tab that expand e reduce the source)

    thanks

     

    giocot

    Attachments



  • 12.  Re: Run a dos command

    Posted Mon March 09, 2015 04:30 AM

    In Canutri's example you can create a 100% width iframe by setting the style property.

    I would make the container of the iFrame responsive, and not the iFrame itself.

    Bram_Callewaert


  • 13.  Re: Run a dos command

    Posted Mon March 09, 2015 05:36 AM
     
    here's an example:

     

    // invoke prova.bat

            SysLib.callCmd("c:\\varie\\WorkFileEGL\\prova.bat");

           

    // verify return code

            result = SysVar.returnCode;

            SysLib.writeStdout("result errorlevel: " + result);

     

     

    aldobarone


  • 14.  Re: Run a dos command

    Posted Mon March 09, 2015 10:24 AM

    SysLib.callCmd() is not valid in RUI.

    EGL library sysLib on IBM Knowledge Center

    Daron

    canutri


  • 15.  Re: Run a dos command

    Posted Mon March 09, 2015 10:28 AM

    Thanks for this input.

    Just to clarify, the syslib.callcmd does support calling out to a Bat file or cmd file, but only from Java, not the genned JavaScript from RUI.

     

    markevans


  • 16.  Re: Run a dos command

    Posted Mon March 09, 2015 11:59 AM

    Hi Bram

    Sorry but i'm not expert in Web,  Html etc..

    i have tried to set 100% width in this way "src =  http://www.ibm.com   border=0  width=100% height=100%" , and the result is in attached img01

    For the  responsive container : can you suggest me example ?

    Thanks  again for your  time

     

     

     

     

    giocot

    Attachments



  • 17.  Re: Run a dos command

    Posted Mon March 09, 2015 12:59 PM

    See if applying single-quotes to the iFrame's property values work.

    <iframe src='http://www.ibm.com' border='0' width='100%' height='100%'></iframe>

    Daron

    canutri


  • 18.  Re: Run a dos command

    Posted Mon March 09, 2015 06:03 PM

    Hi Daron

    Unfortunatly , the rsult is the same  ...

    i also try on w3schools.com and the result is the same; see attached image

    any other idea ?

    Thanks

    giocot

    Attachments



  • 19.  Re: Run a dos command

    Posted Tue March 10, 2015 07:02 AM

    This is interesting.  In my rui code I do not have this problem as I usually set the div container and iframe to the same height & width values.  But in your html code example, the height property does work. when set to 100%.  I copied the html and changed the height value to 1000px and that does work.

    I found an explaination here in the last post of this thread:

    http://stackoverflow.com/questions/325273/make-iframe-to-fit-100-of-containers-remaining-height

    Add this to your html:

    <style>html,body{height:100%}</style>

     

    canutri


  • 20.  Re: Run a dos command

    Posted Tue March 10, 2015 08:46 AM

    Giocot,

    Don't know if it will matter, but one thing I noticed in your screen shot...   You used double quotes ("100%") instead of single quotes ('100%') like Daron showed. 

    Maybe it would make a difference or just go ahead and use the latest suggestion from Daron.

    Mark

    markevans


  • 21.  Re: Run a dos command

    Posted Tue March 10, 2015 11:05 AM

    Hi

    Here the EGL : i don.to kown if is correct like i have added  "<style> html,body{height:100%}</style> "

      content.appendChild(new HTML{text = "   <style> html,body{height:100%}</style>   <iframe src= http://www.ibm.it width=100% height=100% ></iframe>   "});

     

    anyway the result is in the attached image (unfortunatlye it seems don't work as i expected ?

    Thanks

    giocot

    Attachments



  • 22.  Re: Run a dos command

    Posted Tue March 10, 2015 01:06 PM

    Hi Giocot,

    The <style> tag is not going work within the HTML rui widget like that.

    You might try adding the following to your projects .css file:

    HTML, BODY {    height: 100%;    width: 100%;}

    Can you provide a copy of the definition for content?  Is it a Div?

    Daron

    canutri


  • 23.  Re: Run a dos command

    Posted Tue March 10, 2015 02:06 PM

    Hi Daron

     

    attached the egl file and css file

    Thanks for your help

     

    giocot

    Attachments



  • 24.  Re: Run a dos command

    Posted Tue March 10, 2015 08:37 PM

    Hi Giocot,

    The width is going to be limited (restricted) to the width specified by the columnWidths value for the portal widget.  In the example provided, the www.ibm.it link is used in the 3rd portlet which has a width of 300 as seen by the portal definition:

      portal Portal { columns = 3, columnWidths = [ 300, 500, 300 ]   };

    You'll notice that the porlet's width will expand when dragged into the 2nd column.

    Would a DojoTabContainer be more suitable for needs so you can always have the maximum screen size for each application as loaded in each tab?  See the TabContainer example in the LayoutDraw from dojo.samples.Gallery.

    canutri


  • 25.  Re: Run a dos command

    Posted Thu March 12, 2015 11:08 AM

    Hi Daron

    i saw the TabContainer example in the LayoutDraw, but is not exactly what i nedd; my need is display at the same time more application/documents/web pages (typical Portal with portlet!!) .

    In the 3rd portlet, i would that the web page could be resized in according with the width portlet ...  sorry for the request .. i don't know if is it impossible with Egl/Html  .

    Thanks again

    P.S. possible that with Css or JavaScript i can't have find the solution ?

    giocot


  • 26.  Re: Run a dos command

    Posted Thu March 12, 2015 06:34 PM

    Hi Giocot,

    I understand.  So, how much of the browser width will the porlet containing the web pages occupy?  Are you sticking with the portlet dimensions given in the portal project or do you want the portlet to expand as with the browser?

    The web page is not going to always fit in such a small porlet with 300 pixels.  Vertical and Horizontal scrollbars will provided when the web page content does not fit inside the iframes height and width.

    As the portlet is moved to another portal column having a wider or narrower column width may be accommodated with some modification to the portalListener() function's handling of the PortalLibrary.PORTLET_MOVED event.  It would have to drill down into the portlet's content to the iframe and change the width to match that of what is being set for the portlet's content which in this case would be the HTML rui widget.

    Reading back on this tread I also recall you were asking if the portet could be expanded to full width much like what happens in the RBD ide.  I think this too "might" be possible by extending the portlet widget with some modification to add an action to the portlet's actionBar.  Doing this would add an icon to the right-side of the portlet title bar.

    There's no onDoubleClick event in rui, so the only way to implement that would be to have a time interval on the onClick event.  I believe EGL's dateTimeLib is limited with rui.  I haven't done much with time intervals in rui.  I'll see what I can find out.

    Daron

     

    canutri


  • 27.  Re: Run a dos command

    Posted Mon March 16, 2015 05:27 AM

    Hi

    i found the solution:

    in the Egl code

    content Div{id = "wrap", class = "myIframe", layoutData = new GridLayoutData{row = 1, column = 1}, width = "900", height = "300"}; content.appendChild(new HTML{text = "<iframe id ='frame' src= http://www.ibm.com>  </iframe"});

    in the css

    #wrap {      width: 630px;    height: 300px;    padding: 0;    overflow: hidden;}#frame {      -ms-zoom: 0.5;    -ms-transform-origin: 0 0;    -moz-transform: scale(0.5);    -moz-transform-origin: 0px 50px;    -o-transform: scale(0.5);    -o-transform-origin: 0px 50px;    -webkit-transform: scale(0.5);    -webkit-transform-origin: 0 0;}#frame {    width: 1230px;    height: 530px;    overflow: hidden;}

    Thanks

     

     

    giocot