java structure array in SSJS xpages -


i have make call method of web service via ssjs. 1 of input parameters of method structure array. web service consumer implemented in java. know how declare , instantiate java strucuture array in ssjs.

the signature of method is:

(short , short , java.lang.string , java.lang.string , java.lang.string , java.lang.string , java.lang.string , java.lang.string , java.lang.string , short , java.lang.string , java.lang.string , estruturachecklist[] )

i creating array per suggestion:

lst=new arraylist();  var chk:xx.xxx.xxxx.xxxx.estruturachecklist=new  xx.xxx.xxxx.xxxx.estruturachecklist(); chk.setconteudochecklist("xxxx"); chk.setdescricaochecklist("cÓdigo usuÁrio"); lst.add(chk);  var chk1:xx.xxx.xxxx.xxxx..estruturachecklist=new  xx.xxx.xxxx.xxxx..estruturachecklist(); chk1.setconteudochecklist("teste"); chk1.setdescricaochecklist("nome usuario"); lst.add(chk1); var chk2:xx.xxx.xxxx.xxxx..estruturachecklist=new  xx.xxx.xxxx.xxxx..estruturachecklist(); chk2.setconteudochecklist("teste notes"); chk2.setdescricaochecklist("nome notes"); lst.add(chk2); arr=lst.toarray();  

when created structure array following suggestion, java method gives error , not recognize last array. sure, changed signature of class instantiates web service client removing array, there no error. think occurring java class not recognizing array passed ssjs array of specified structure.

the error calling method is:

error while executing javascript action expression script interpreter error, line=75, col=13: java method 'xxxxx(number, number, string, string, string, string,string, string,string, string,string, [ljava.lang.object;)'on java class xx.xxxx.xxxx.xxx not found

if need java array of given objects, can first put them in list-like structure, arraylist or vector, , afterwards retrieve java array calling toarray method.

here ssjs code snippet should you:

importpackage(java.util); importpackage(br.com.mercantil.dmdws);  var lst,chk,arr;  lst=new arraylist();  chk=new estruturachecklist(); // ... whatever need object lst.add(chk);  // ... repeat previous step if needed  arr=lst.toarray(); // java array 

update

if method use cannot handle object array because demands array of class can provide array needed runtime type first argument toarray method. not know how create or cast such array in ssjs add "helper" method br.com.mercantil.dmdws.estruturachecklist class looks this

public static estruturachecklist[] getjavaarray(int n) {     return new estruturachecklist[n]; } 

and create array in example above in following way:

arr=lst.toarray(estruturachecklist.getjavaarray(lst.size())); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -