Solution model exceptions

Could it be an idea, to throw exceptions if you want to change a form by the solutionmodel and the form has already been loaded.

I just found that I have lot of troubles because somewhere a form was unexpected loaded earlier than I thought and that caused a lot of troubles.

this is already implemented for some time now, will be in 4.1.4

Under what case # I can see this fix in the release announcement?

that wasnt listed it was an internal thing.

But if you touch a solution model form instance and the ui instance of that form was already there and not destroyed you should get a error in the developer.

I can confirm that this has changed with 4.1.4 and I get the error message seen attached. I had to correct it with the command history.removeForm(formName); before using var form = solutionModel.getForm(formName); and setting solution properties like for example

var paneFooter = form.newLabel(null, btnPosX, btnPosY, 220, 18);
	
// Set properties for pane footer (gradient) graphic
paneFooter.name = 'paneFooter';
paneFooter.styleClass = 'Default';
paneFooter.borderType = 'EmptyBorder, 0, 0, 0, 0';
paneFooter.imageMedia = solutionModel.getMedia('paneFooterGradientBG.png');
paneFooter.mediaOptions = SM_MEDIAOPTION.ENLARGE;
paneFooter.anchors = SM_ANCHOR.WEST | SM_ANCHOR.SOUTH | SM_ANCHOR.EAST;
paneFooter.showClick = false;
paneFooter.showFocus = false;
...

I have assumed that the cmd solutionModel.removeForm(); would do it too, but that doesn’t work. Johann, could you say why? It would be more logical me to use this cmd. What is it now used for?

Regards, Robert

jcompagner:
that wasnt listed it was an internal thing.

But if you touch a solution model form instance and the ui instance of that form was already there and not destroyed you should get a error in the developer.

solutionModel.removeForm() really deletes the form from the blueprint so you cant reuse it then and have to create that form again.

But if you call solutionModel.removeForm() on a form that is visible it will return false. And then if you modify it after that you will get the error.
So my guess is that sm.removeForm() really couldnt remove it.

But history.removeForm() also shouldnt help then because sm.remove calls history.remove to remove the live form instance
and then sm.remove also does something extra and deletes the form from the solution blueprint.

But looking at your example you really have to call history.remove() then get the form from the solution model and alter properties
if you would call solutionModel.remove then the call to get the form from the solution model should return null.
(if solutionModel.removeForm would return true)

Hi Johann

Two uncertainties remain: What do you mean exactly by visible and what is your blueprint technically?

Below is my code in more detail. The code is used to create the (body) footer with a button to get the reports menu and appears everytime a menu is selected. A menu can of course be selected many times. The relevant code looks (shortened) like this:

Code of the menu selection (a big case stmt). The menu 801 for example is in domain SCHULE > Fachpersonen (I added a screenshot as an aid to read the code)

function handleMenuSelected()
{
	/*
	Title:		The form will be shown. Register at domains form.
	
	Author:		Birgit Rieder, Robert Huber
	Created:	19.07.2007
	Modified:	05.08.2008,	hu: Default form for find mode for each menu added, stored in form variable this.defaultForm.
				06.10.2008,	hu: Menu sequence changed to Kanti-Feedback.
	
	Arguments:	-
	Returns:	-
	Notes:		-
	*/
	
	var menuId = forms.BasConfiguration.getConfiguration().selectedMenuId;
	
	// Save the divider location for the main form and the last menu id:
	var dividerLocation = elements.vSplit.dividerLocation;
	forms.BasConfiguration.getConfiguration().setMainDividerLocation(dividerLocation); // Saves location and previous selected menu id
	
	// Save the divider locations for all the forms showed.
	forms.BasConfiguration.saveDividerLocationForFormName(elements.tabSelection.getTabFormNameAt(1));
	forms.BasConfiguration.saveDividerLocationForFormName(elements.tabDetail.getTabFormNameAt(1));
	
	elements.tabSelection.removeAllTabs();
	elements.tabDetail.removeAllTabs();
	
	elements.vSplit.leftComponent = elements.tabSelection; // Restore 1st tabpanel assignment in case it has been set to null
	
	this.findForms = new Array(); // Forms to set into find mode when a find (Cmd-F) is done
	
	switch(menuId)
	{
		...
		case 801:
		globals.createTabSelectionFooter('ScoSubjects', 0, 36);
		globals.createTabDetailFooter('ScoPersonsCapabilities', 0, 682);
		elements.tabSelection.addTab(forms.ScoSubjects, null, null, null, null, null, null);
		elements.tabDetail.addTab(forms.ScoPersonsCapabilities, null, null, null, null, null, null);
		break;
		...
	}

Everytime, menu “801” is selected, the method globals.createTabSelectionFooter() is called (beside the other methods). The mothod looks like:

function createTabSelectionFooter()
{
	/*
	Title:		The background image will be dynamically created with the solution model.
	
	Author:		Robert Huber
	Created:	01.09.2009
	Modified:	-
	
	Arguments:	String : Form to create footer part
				Integer : x position of button
				Integer : y position of button
	Returns:	-
	Notes:		The gradient background image paneFooterGradientBG.png will be appended to the right of existing buttons
	*/
		
	var formName = arguments[0];
	var btnPosX = arguments[1];
	var btnPosY = arguments[2];

	// Remove form from history first to get a pre runtime state to add elements with the solution model to it (witout getting stale forms detected error)
	history.removeForm(formName); // Works!
	//solutionModel.removeForm(); // Doesn't work

	// Add background image paneFooterGradientBG.png to footer part
	var form = solutionModel.getForm(formName); // Get form to add footer element to	
	var paneFooter = form.newLabel(null, btnPosX, btnPosY, 220, 18);
	
	// Set properties for pane footer (gradient) graphic
	paneFooter.name = 'paneFooter';
	paneFooter.styleClass = 'Default';
	paneFooter.borderType = 'EmptyBorder, 0, 0, 0, 0';
	paneFooter.imageMedia = solutionModel.getMedia('paneFooterGradientBG.png');
	paneFooter.mediaOptions = SM_MEDIAOPTION.ENLARGE;
	paneFooter.anchors = SM_ANCHOR.WEST | SM_ANCHOR.SOUTH | SM_ANCHOR.EAST;
	paneFooter.showClick = false;
	paneFooter.showFocus = false;
}

So I still don’t understand exactly why one works and the other doesn’t.

Regards, Robert

form visible: if it is shown as the main form or in a visible tab.

blueprint: the solutionModel stuff. var form = solutionModel.getForm(formName) == blueprint, forms.formname == ui instance created from the blueprint.

solutionModel.removeForm(formName); // Doesn't work
var form = solutionModel.getForm(formName); // Get form to add footer element to

this is logical see my previous post.
If you call solutionModel.removeForm(formName)
then solutionModel.getForm(formName) will return null. Because you have removed the form from the blueprint. It is gone/deleted.

history.removeForm() will delete/remove the UI instance and then it can be recreated again from the forms blueprint.