Pages - Menu

Saturday, September 14, 2013

Execute & Run Client Side Resources || Oracle ADF

Today i will publish a solution to access Client Side Resource from Oracle ADF applications, and as per my knowledge, we have 2 ways, First One Java Script & Second is Java Applets ..
i recommend use Java Script in ADF - JSF Pages in our case ..
sometimes, Client need to access Client Resources to run exe,bat or vbs files, so i created simple script work with Microsoft Internet Explorer & Mozilla FireFox used to execute vbs file, but first you have to know 3 important points.
1- any JSF Component you will use to get data or execute js script should be client Component property = true.
2- you have to use js tag <af:resource type=”javascript”> to include Java Script Resources and call it using Client Listener <af:clientListener method=”RunSDS” type=”action”/>
3- Activate FireFox option Signed.Applets.codebase Principal Support using about:config in FireFox URL.
My Example: showes Calling vbs file with unique parameter to execute Client Side vbs script ..
<af:resource type=”javascript”>
              function RunSDS(evt) {
                  var MyClaim = AdfPage.PAGE.findComponent(“pt1:ot9”);
                  if (MyClaim.getValue() != null) {
                      evt = window.event;
                      if (navigator.appName == ‘Microsoft Internet Explorer’) {
                          var commandtoRun = “c:\run\Execute.vbs”;
                          var objShell = new ActiveXObject(“Shell.Application”);
                          objShell.ShellExecute(commandtoRun, MyClaim.getValue(), “”, “open”, 0);
                      }
                      else {
                          try {
                              netscape.security.PrivilegeManager.enablePrivilege(“UniversalXPConnect”);
                              var exe = window.Components.classes[‘@mozilla.org/file/local;1’].createInstance(Components.interfaces.nsILocalFile);
                              exe.initWithPath(“c:\run\Execute.vbs”);
                              var run = window.Components.classes[‘@mozilla.org/process/util;1’].createInstance(Components.interfaces.nsIProcess);
                              run.init(exe);
                              var parameters = [MyClaim.getValue()];
                              run.run(false, parameters, parameters.length);
                          }
                          catch (ex) {
                              alert(ex.toString());
                          };
                      };
                  };
              }
</af:resource>

No comments:

Post a Comment