happytigger:
I have a function to create the form:
function createForm()
{
var fname = “newForm”;
var dataSet = databaseManager.getDataSetByQuery(‘my_db’, sql, null, -1);
for (var i = 1; i < dataSet.getMaxRowIndex(); i++)
{
var number = dataSet.getValue(i, 2);
var name = dataSet.getValue(i, 1);
var js = ‘<a href="javascript:globals.showDetail(’ + “'” + name + “'” + ‘)">’ +
+ number + ‘’;
dataSet.setValue(i, 2, js);
}
var uri = dataSet.createDataSource(
'mydata', [DM_COLUMNTYPE.TEXT, DM_COLUMNTYPE.INTEGER, DM_COLUMNTYPE.INTEGER,
DM_COLUMNTYPE.INTEGER, DM_COLUMNTYPE.TEXT, DM_COLUMNTYPE.INTEGER, DM_COLUMNTYPE.TEXT,
DM_COLUMNTYPE.TEXT]);
var jsform = solutionModel.newForm(fname, uri, null, true, 400, 700);
var fieldn = buildField(jsform, "name", "Name", 120);
fieldn = buildField(jsform, "media_num", "Tapes", 70, true);
fieldn = buildField(jsform, "ready", "Ready", 70);
................//Create fields
forms[fname].controller.show();
}
function buildField()
{
var form = arguments[0];
var fieldName = arguments[1];
var label = arguments[2];
var width = typeof(arguments[3]) == ‘undefined’ ? 100 : arguments[3];
var htmlArea = arguments[4] == true ? true : false;
var newArea;
if (htmlArea)
{
newArea = form.newHtmlArea(fieldName, form.getFields().length, 31, width, 22);
}
else
{
newArea = form.newTextField(fieldName, form.getFields().length, 31, width, 22);
}
newArea.text = label;
newArea.editable = false;
return newArea;
}
function showDetail() //Create a new form
{
var args = new Array();
args[0] = arguments[0];
var dataSet = databaseManager.getDataSetByQuery(‘my_db’, sql, args, -1);
var fname = “detailForm”;
var uri = dataSet.createDataSource(
‘mydata’, [DM_COLUMNTYPE.TEXT, DM_COLUMNTYPE.TEXT, DM_COLUMNTYPE.TEXT, DM_COLUMNTYPE.TEXT]);
var fieldn = buildField(jsform, “code”, “Barcode”, 100);
… //Create fields
forms[fname].controller.show();
}
I already tested that it did call showDetail() but it threw the exception "Could not eval the string 'globals.showDetail()'" when calling "var dataSet = databaseManager.getDataSetByQuery('my_db', sql, args, -1)" in showDetail(). I can do anything else in showDetail() but calling databaseManager.getDataSetByQuery().
Thanks,
Your code seems a bit weird to me (no offense
.
I don’t know really what’s in your ‘sql’ variable but what I understand from the above is that in your createForm() function:
- first you get a number from your database (in column 2),
- then you build a string from it and insert into the same column (?)
- and after that you create a datasource from that dataset, specifying that the second column is of type integer (DM_COLUMNTYPE.INTEGER)
So I would guess that when you are trying to pull the dataset back with the getDataSetByQuery(…) in showDetail(), Servoy chokes because it tries to interpret your string or number or I don’t know what it is after all this!.
I don’t know how sensitive Servoy’s JavaScript is to the database types, but I know that in java, it would never work…
Maybe you intended to do “dataSet.setValue(i, 1, js);” or maybe the type of args in showDetail is not what you think, anyway I would check for the type of variables and maybe the sql variable itself because it seems that it either sql or args in showDetail() contains “'globals.showDetail()”.
That’s only a few ideas. Hope this helps,