android - Worklight HTTP adapter procedure being called multiple times despite being executed only once -


i have application created using worklight 5.0.5. in app make call http adapter retrieve lot of data (all contacts of company); operation takes 1 minute produce response. adapter calls servlet returns of requested data.

a strange thing happens after tap button start call adapter procedure: in servlet logs see after 30 seconds second call arrives same command, didn't tap button or call adapter procedure again!

the procedure timeout set 120 seconds:

<procedure name="getcontlistjson" requesttimeoutinseconds="120"/> 

and code call adapter procedure is:

function loadcontactlist(){       if(firstloadcontacts){         loadcontresults = null;         var busy = new wl.busyindicator("content", { text: "caricamento lista contatti..."         });         busy.show(); // show busy indicator         var invocationdata = {             adapter : 'dominoadapterhttp',             procedure : 'getcontlistjson',             parameters : []         };         wl.logger.debug("loading contacts list server");         wl.client.invokeprocedure(invocationdata, {             onsuccess : dojo.hitch(this, function(resultc) {             busy.hide();             wl.logger.debug("load contacts completed: ", resultc);             if (resultc.invocationresult.items.length !== 0) {                 loadcontresults = resultc.invocationresult;                 this.listcontacts();             } else {                 //alert("nessun ordine presente nello stato selezionato");             }         }),         onfailure : dojo.hitch(this, function (result) {             busy.hide();             wl.logger.debug("load contacts failed: ", resultc);             alert("error loading data: " + json.stringify(resultc));         }),         timeout:120000     });      } else {         this.listcontacts();     } } 

i cannot understand why second call starts automatically. behavior implies app doesn't continue operations display results , in of cases error "host not available".

edit:

with simplified code had same problem:

var invocationdata1 = {         adapter : 'dominoadapterhttp',         procedure : 'getcontlistjson',         parameters : [] }; wl.logger.debug("loading contacts list server");  wl.client.invokeprocedure(invocationdata1, {     onsuccess : function(resultc){alert('ok!');},     onfailure : function(resultc){alert('ko');},     timeout:120000 }); 

backend code:

if (command.equalsignorecase("getcontactsjson")){  system.out.println("" + mblappdominoquery.class.getname() + ": getcontacts method called");          long starttime = system.currenttimemillis();          try{             //notesthread.sinitthread();             session newsession = notesfactory.createsession("192.168.x.x","user","pwd");     system.out.println("platform --> " + newsession.getplatform());     system.out.println("username --> " + newsession.getusername());             //system.out.println(system.getproperty("java.library.path"));             database databasenew = newsession.getdatabase ("192.168.x.x", "prj/db.nsf");              view viewclienti = databasenew.getview("(rubrica contatti - tutti)");     system.out.println("# contatti: " + viewclienti.getentrycount());             viewentrycollection vec = viewclienti.getallentries();              viewentry tmpentry;             viewentry entry = vec.getfirstentry();             string jsonresp = "{ \"items\": [";              while (entry != null) {                  string cod = entry.getdocument().getitemvaluestring("company_num");                 string cli = entry.getdocument().getitemvaluestring("company_name");                 string nome = entry.getdocument().getitemvaluestring("fname");                 string cognome = entry.getdocument().getitemvaluestring("lname");                 string mansione = entry.getdocument().getitemvaluestring("mansione");                  if(cli.indexof('\"') != -1 || cli.contains("\"")){                     cli = cli.replace("\"", "\'");                  }                  cli = new mblappdominoquery().removeaccents(cli);                 nome = new mblappdominoquery().removeaccents(nome);                 cognome = new mblappdominoquery().removeaccents(cognome);                  if(mansione != null && mansione.length() > 30)                     mansione = mansione.substring(0, 30) + "...";                 if(cli != null && cli.length() > 30)                     cli = cli.substring(0, 30) + "...";                  string label = "<table><tr><td>" + cognome + " " + nome + "</td></tr><tr><td style=\\\"font-size: small; color: silver;\\\">" + mansione + "</td></tr><tr><td style=\\\"font-size: small; color: silver;\\\">" + cli + "</td></tr></table>";                 string id = "" + cod + "*" + nome + "*" + cognome + "*" + mansione;                   jsonresp += " { \"id\": \"" + id + "\", ";                 jsonresp += " \"moveto\": \"contactdetails_1\", ";                 jsonresp += " \"transition\": \"slide\", ";                 jsonresp += " \"variableheight\": true, ";                 jsonresp += "\"label\": \"" + label + "\" },";                  tmpentry = vec.getnextentry();                  entry.recycle();                  entry = tmpentry;              }              jsonresp = jsonresp.substring(0, jsonresp.length()-1);             jsonresp += "] }";              jsonobject json = new jsonobject();             try {                 json = (jsonobject) new jsonparser().parse(jsonresp);                 //system.out.println("json: " + json);             } catch (parseexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }              long stoptime = system.currenttimemillis();             long elapsedtime = stoptime - starttime; system.out.println("elaborazione completata in: " + (new simpledateformat("mm:ss:sss")).format(new date(elapsedtime)) + " minuti");             response.setcontenttype("application/json");             response.getwriter().write(json.tostring());           }catch (exception e) {             // todo: handle exception             e.printstacktrace();         }finally{             //notesthread.stermthread();         }    } 


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -