Hi,
I would like to know if the following is behavior like it should be.
I have a solution with 2 forms (firstForm and secondForm). the firstForm is the first form to show on startup solution.
The secondForm is not shown. It is just designed.
I decide to remove that second form, using the following coding:
var _ok
var _form = 'secondForm'
// Remove form from history
_ok = history.removeForm(_form);
if (! _ok)
application.output('Error in remove history');
// Remove form from solution model
_ok = solutionModel.removeForm(_form);
if (! _ok)
application.output('Error in remove solution model');
var _jsForm = solutionModel.getForm(_form)
if (_jsForm == null)
application.output('Form not found, like expected')
else
application.output('Formobject returned, unwanted');
When running my solution, I get message “Formobject returned, unwanted”. That is not what I expected, because I removed the form from the solutionModel.
When I run the coding twice, then I get:
Error in remove history
Error in remove solution model
Formobject returned, unwanted
The errormessages seem to be logic, because I removed the form from the solutionModel.
Is there something missing, or is this a bug (Servoy 5.1.4)
Martin
I think it is a bug.
When I show all forms as out using forms.allnames
then this situation seems only to occur on the last formname in the array
Martin,
solutionModel.removeForm(_form) will revert the form to the state as it was in the original solution (before any solution model actions).
So a new form will be deleted, but a form that exists in the designed solution will be reverted.
Rob
** edit **
I was wrong in this, solution.revertForm() should do this, solutionModel.removeForm() should remove a form, even if it is was in the original design-time solution.
Rob
this is a bug yes if a changed designed solution isn’t removed
I looked at the code and it should remove it (hide it) completely. But there could be a bug because it is changed first.
The thing i ask is why do you want to remove a designed form anyway? What do you want to achieve?
It is not memory usage that you gain, because a designed form is not really gone it is just hidden.
Do you want to create another form that has the same name? So that you completely replace it?
jcompagner:
Do you want to create another form that has the same name? So that you completely replace it?
Yes that was the situation, but I made a workaround for that.
I had forms that were designed and those forms need to be generated now using the SM.
But because I didn’t want to remove the original forms yet, I thought I could solve it like this.
And it worked, except some form(s).
And I saw it went wrong on the form(s) that was the shown last when I print forms.allnames
But as I said, I made a workaround and don’t have the problem anymore
i did fix this problem, it was only reproducible if you altered a module form and wanted to remove that.