Topic
  • 4 replies
  • Latest Post - ‏2012-12-10T17:18:37Z by XAA
XAA
XAA
25 Posts

Pinned topic How to use a global variable like a parameter in Javascript?

‏2012-12-05T14:41:58Z |
Hi,
I'm developing with RBD 8.5 and HATS 8.5. And I'm trying to execute or open in a client side a program like word, excel, acrobat,... wich path is passed by 5250 screen in a GV that I have retrieved previously. I'm having some problems with the script to use.

I'm trying something like this to retrieve the GV:

<%
String var1="";
var1= ((TransformInfo)request.getAttribute(CommonConstants.REQ_TRANSFORMINFO)).getGlobalVariable("GV1", true).getString(0);
var1 = var1.trim();
%>

I expect that "GV1" contents the string with the path for the program I want to execute client side through HATS. But, anyone knows which script I have to use now? Or if I need something else?
Thanks in advance,
XA
Updated on 2012-12-10T17:18:37Z at 2012-12-10T17:18:37Z by XAA
  • tmparker
    tmparker
    519 Posts

    Re: How to use a global variable like a parameter in Javascript?

    ‏2012-12-05T14:51:42Z  
    There is no easy way to do this. The security of browsers prevents you from trying to execute local applications on the workstation. Can you imagine how bad things would be if you could simply write JavaScript and start executing local applications on a user's machine? You could write and ActiveX control and embed that in the page and then you could interact with that; however, that will only work in IE. Each browser has it's own API and there may be a way to do this but all solutions will be browser specific. The only other option would be to write a Java applet that is signed and then you may possibly be able to execute the code on a client workstation. Not sure if Java has closed that functionality as well for security reasons or if that's still available. Basically this kind of functionality is not allowed for obvious reasons and you would have to create a very custom workaround to try to make it happen.

    Thanks
    Tim
  • XAA
    XAA
    25 Posts

    Re: How to use a global variable like a parameter in Javascript?

    ‏2012-12-05T15:08:34Z  
    Thanks Tim,
    I was trying to call a function like this:

    function cmd() {
    w = new ActiveXObject("WScript.Shell");
    w.run("GV1");
    return true;
    }

    and calling function just before the end of the body page.

    <script type="text/javascript" language="javascript">
    cmd();
    </script>

    As you said, I realize that it will only probably works with IE. But I don't know how to manage the parameter GV1 in the script. Any idea how could it work in a tablet as well?
    Thanks again,
    XA
  • tmparker
    tmparker
    519 Posts

    Re: How to use a global variable like a parameter in Javascript?

    ‏2012-12-05T15:57:10Z  
    • XAA
    • ‏2012-12-05T15:08:34Z
    Thanks Tim,
    I was trying to call a function like this:

    function cmd() {
    w = new ActiveXObject("WScript.Shell");
    w.run("GV1");
    return true;
    }

    and calling function just before the end of the body page.

    <script type="text/javascript" language="javascript">
    cmd();
    </script>

    As you said, I realize that it will only probably works with IE. But I don't know how to manage the parameter GV1 in the script. Any idea how could it work in a tablet as well?
    Thanks again,
    XA
    OK, sorry, that part is easy. You simply use JSP code to insert into the value dynamically. It would look something like this:
    
    <% String var1=
    ""; var1= ((TransformInfo)request.getAttribute(CommonConstants.REQ_TRANSFORMINFO)).getGlobalVariable(
    "GV1", 
    
    true).getString(0); var1 = var1.trim(); %>   <script type=
    "text/javascript" language=
    "javascript"> function cmd() 
    { w = 
    
    new ActiveXObject(
    "WScript.Shell"); w.run(
    "<%=var1%>"); 
    
    return 
    
    true; 
    } </script>
    


    Thanks
    Tim
  • XAA
    XAA
    25 Posts

    Re: How to use a global variable like a parameter in Javascript?

    ‏2012-12-10T17:18:37Z  
    Hi Tim,
    The client side execution I tried with ActiveX is not working. Actually, the server side is executing in 5250 screen a RUNPCCMD command through iSeries Access for Windows Remote service to open a program (excel, acrobat, word,...) with iseries data.
    Could I do the same through HATS Web project?
    Thanks ahgain,
    XA