I’m getting a strange behaviour from my program. I use a button which triggers a method which should show a form. But I need to click twice for the form to appear.
I have traced it using debugger and breakpoints and discovered that on the first click it runs the line which shows the form but doesn’t trigger its onShow method (doesn’t reach the breakpoint in the onShow method). Then if you click a second time it runs the onShow method and displays the form.
Here is the code triggered when you click the button:
function TransferStockOut()
{
if (globals.FilterEPC != null)
{
elements.tabs_stock_details.tabIndex=2;
globals.StockTransferring=1;
globals.StockTransferAction=null;
globals.StockTransferEPC=null;
globals.StockTransferNote=null;
databaseManager.startTransaction();
application.showFormInDialog(forms.frm_stock_transfer_out, null ,null ,null ,null , "Stock Transfer Out", false, false,"Transfer_Out" , true);
}else {
globals.ShowWarning("Please Select Individual EPC in Tree to Transfer Stock");
}
}
This is a consistent behaviour which appears on both Developer and Server.
I use Servoy version 5.0.1 - build 861
are you talking about the onShow of the form attached to the tab panel or the one displayed with showFormInDialog?
also, the onshow method may stop before the breakpoint?
I’m talking about the onShow of the form displayed with showFormInDialog.
The breakpoint is placed inside the onShow method (called “Init”) at the very first line.
On the first click the debugger doesn’t stop at the breakpoint but the tab panel is switched correctly (using the index) and we go out of TransferStockOut()
On the second click it does stop at the breakpoint.
weird… do you have a method for “ontabchange” which would stop the current method? because, it seems that your method works once tab 2 is active already.
lesouef:
weird… do you have a method for “ontabchange” which would stop the current method? because, it seems that your method works once tab 2 is active already.
There is no method called by “ontabchange”. I already tried to change manually the tab before clicking to show the form, but it doesn’t change anything.
Also, I didn’t mentioned it before, but once the form has been displayed, you can close and re-open form again, it works well each time. It looks like something is initialised at the first try, but all the code run is in my first post.
in which form is cmb_EPC element?
if this is not the right track, just replace the whole method by application.output(“got it”) and see if it stops there.
cmb_EPC is in the form I try to display (frm_stock_transfer_out)
I have tried to display another form instead of this one, and it works fine and the onShow method is called normally.
I have created a new method called Test in the form I want to show. It prints a message in the console.
I have switched the onShow method with this one.
But when I run the program and click on the button to show the form I get exactly the same behaviour: nothing displayed on the first click.
interesting, probably a parameter which is not displayed, or a new feature which is left undefined by the conversion.
I have converted 2 solutions from 3.5 and I saw that onshow methods are kept, but they receive JSEvent as argument, while a newly created have 2 arguments. So how is it from 4 to 5? if you remove and re-create the onshow setting in your form, does it change from 1 arg to 2?
lesouef:
interesting, probably a parameter which is not displayed, or a new feature which is left undefined by the conversion.
I have converted 2 solutions from 3.5 and I saw that onshow methods are kept, but they receive JSEvent as argument, while a newly created have 2 arguments. So how is it from 4 to 5? if you remove and re-create the onshow setting in your form, does it change from 1 arg to 2?
Sorry, I have deleted my reply because it didn’t fix it in fact! It worked the first time but after same issue. I probably forgot to relaunch the program?!
Anyway, I have done more tests and found that the valuelist linked to one of the combobox of the form is causing the problem! When I remove it and put ‘-none-’ instead it works fine on the first click.
Here are the details of the combobox and the value list:
[attachment=1]Capture1.PNG[/attachment] [attachment=0]Capture2.PNG[/attachment]
The weird thing is that, this valuelist seems to work fine when the form is displayed. The data in the combobox is correct.
why is it editable? this is normally a warning when the list is based on records fields. no idea why this would stop the method? maybe building the list is not possible before the form is displayed because the relation is not true yet? put a custom list for a test?
We did more tests, as you advised, in the relations type and finally discovered that valuelists generated using relations have to be loaded before using them in the combobox if there is a big amount of data to display.
We have first tested with a simple customized valuelist: No problem, it worked.
We have then tried with table values using a table which returns many rows (200+): No Problem, it worked.
We have then tried with related values using a relation which returns few rows: No Problem, it worked.
So, we have tried to do a “globals.the_relation.loadAllRecords();” before showing the form and it worked!
Apparently, Servoy is not able to load all the data before displaying the form and crash or fail.
This worked in Servoy 4
combo boxes with more then lets say 50 items i already find a usability issue, not to mention more then 200…
If you have such a list then the best thing is to use a TYPE_AHEAD so that a user can type and filter.
I don’t even remember why I asked this q.
probably because my value lists is a table of all value_lists together, since I use the “valuelist name as filter” a lot, and I edit them all in the same place.
I fixed that by using a
databaseManager.getDataSetByQuery(‘db’, $query, null,10000)
by the way, using a select query with a limit 0,10000 does not work, it has to be set as a getDataSetByQuery argument.