I want to reuse the methods from a Java Object I get from a plugin I’m developing. One of this methods needs a Java Array to be initialized.
That’s why I need a Java array
Hi tparry
I’ve tried your code, but Servoy throws this exception
The choice of Java constructor setWidths matching JavaScript argument types ([Ljava.lang.Number;) is ambiguous; candidate constructors are:
void setWidths(float)
void setWidths(int) (C:\Users\roberto\Programas\servoy.6\servoy.workspace.pericias.central.v2\rj_pericias_central_v2\forms\menu_casos.js#65)
The choice of Java constructor setWidths matching JavaScript argument types ([Ljava.lang.Number;) is ambiguous; candidate constructors are:
void setWidths(float)
void setWidths(int) (C:\Users\roberto\Programas\servoy.6\servoy.workspace.pericias.central.v2\rj_pericias_central_v2\forms\menu_casos.js#65)
at C:\Users\roberto\Programas\servoy.6\servoy.workspace.pericias.central.v2\rj_pericias_central_v2\forms\menu_casos.js:65 (onAction)
This is the code I’m trying
var jdoc = plugins.iTextRTF.JDoc(); // Initialize plugin
jdoc.initDoc(); // Initialize doc
var doc = jdoc.getDoc(); // Get Java Document Object
doc.open(); // Open doc to be written
var table = itext.Table(3); // Get Java Table Object
// Java Array to set the Table widths
var widths = new java.lang.reflect.Array.newInstance(java.lang.Number, 5);
widths[0] = 1;
widths[1] = 2;
widths[2] = 2;
table.setWidths(widths); // Table widths
I’d rather change the setter for widths. Change it to take an Object and then have your JS method just pass a JS array. Many plugins work with arrays and they do not need to be native Java arrays.