JavaScript in Java code throwing exception -


i'm trying call javascript function java code. code follows:

scriptenginemanager manager = new scriptenginemanager();                 scriptengine engine = manager.getenginebyname("javascript");                  string script = baseurl + "uiconfigurator/includes/js/datacaptureframework.js";                                     try {                     logger.info("evaluating engine");                     logger.info(script);                     url url1 = new url(script);                     logger.info("url1 "+url1.getpath()+url1);                      bufferedreader in = new bufferedreader(                     new inputstreamreader(url1.openstream()));                     string inputline = null;                     stringbuffer buffer = new stringbuffer();                     while ((inputline = in.readline()) != null)                         buffer.append(inputline);                                        logger.info(buffer.tostring());                     engine.eval(buffer.tostring());                                        } catch (exception e) {                     // todo auto-generated catch block                     logger.error(e.tostring());                     logger.error("throwing error in catch part");                  }                 invocable inv = (invocable) engine;                 try {                     logger.info("invoking function");                     inv.invokefunction("displaydatacapturepopup("+user.getorgid()+","+user.getid()+","+session.getlogintype()+");");                 } catch (nosuchmethodexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                 } catch (scriptexception e) {                     // todo auto-generated catch block                     logger.error("throwing error in catch block of invoking engine , function");                 } 

when run code gives me following error:

11:53:50,847 error [login] javax.script.scriptexception: sun.org.mozilla.javascript.internal.ecmaerror: referenceerror: "jquery" not defined. (#1) in @ line number 1 11:53:50,847 error [login] throwing error in catch part 11:53:50,848 info [login] invoking function 11:53:50,848 error [stderr] java.lang.nosuchmethodexception: no such method: displaydatacapturepopup(301,1373864,0);

i tried lot of things still cannot rid of this. please tell me i'm doing wrong. i'm trying call below function javascript.

function displaydatacapturepopup(orgid,userid,logintypeid){ jquery("              <link/>", {rel: "stylesheet",type: "text/css",href:  "/uiconfigurator/includes/css/librarycss/jquery-ui.min.css"}).appendto("head"); jquery("<link/>", {rel: "stylesheet",type: "text/css",href:  "/uiconfigurator/includes/css/datacaptureframework.css"}).appendto("head"); jquery("<link/>", {rel: "stylesheet",type: "text/css",href:  "/uiconfigurator/includes/css/librarycss/tooltipster.css"}).appendto("head");   jquery("<link/>", {rel: "stylesheet",type: "text/css",href:  "/uiconfigurator/includes/css/librarycss/jquery.alerts.css"}).appendto("head");  jquery.getscript('/uiconfigurator/includes/js/uiajaxinteraction.js',function()  {        jquery.getscript('/ionjslib/js/jquery-ui-1.10.4.min.js',function()      {            jquery.getscript('/ionjslib/js/jquery.tooltipster.min.js',function()            {                jquery.getscript('/uiconfigurator/includes/js/libraryjs/jquery.alerts.js',function()                {                    jquery.getscript('/ionjslib/js/jquery.blockui.js',function()                    {                        getdatacapturepopupdetails(orgid,userid,logintypeid);                           }                 );                                                                                               }                 );                                                                                           }                 );                                                                               }                 );                                                                                   }                 );                                                         } 

scriptengine runs javascript in entirely separate environment, no access browser. looks you're trying use show kind of popup in browser; not work. if need control browser remotely, need use different api, not scriptengine.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -