# Solution Model Getting Stale form(s) detected

**URL:** <https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137>\
**Category:** Classic Servoy\
**Created:** [August 26, 2014, 4:32am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137 "2014-08-26T04:32:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![hareendra](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@hareendra](https://forum.servoy.com/u/hareendra)\
**Post date:** [August 26, 2014, 4:32am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/1 "2014-08-26T04:32:32Z")

</div>

Hi,

I am trying to add a onAction() method to a label created via the solution model. When I try to set the style (of a JSLabel) I get the error  
“Stale form(s) detected, form(s) were altered by the solution model without destroying them first  
The form(s) that are stale (can also be a parent form if form inheritance is used) are:”

Here is my code.

```auto
jsLabel = jsform.newLabel(row[0], (2 + ((index-1) * 122)), 10, 120, 20);
		jsLabel.styleClass = 'tab_inactive';
	    jsLabel.showClick = false;
	    
		
		if ( sLastForm != row[1] ) {
	        // Get the new method definition
	        jsFunction = jsform.newMethod('function onActionTab' +index+'() { 
	                                        forms.frm_navigation_bar.jsLabel.styleClass = "tab_active"; }');
	        // remember which form we last processed
	        sLastForm = row[1];
	    }

```

The moment this function runs I get the above error. Any ideas?

Regards,  
Hareendra

---

<div class="post-metadata">

**Author:** ![jdbruijn](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@jdbruijn](https://forum.servoy.com/u/jdbruijn)\
**Post date:** [August 26, 2014, 6:37am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/2 "2014-08-26T06:37:26Z")

</div>

It means that the form has already been loaded by servoy. If you want to change the blueprint of this form with the solutionModel then you have to remove it from the history:

```auto
history.removeForm(formName)

```

---

<div class="post-metadata">

**Author:** ![hareendra](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@hareendra](https://forum.servoy.com/u/hareendra)\
**Post date:** [August 26, 2014, 6:54am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/3 "2014-08-26T06:54:30Z")

</div>

Hi,

I tried the following,

```auto
 jsFunction = jsform.newMethod('function onActionTab' +index+'() { \
	                                        forms.frm_main.addNewTab("' + row[1] + '"); \
	                                        history.removeForm("'+sform+'");\
	                                        forms.frm_navigation_bar.jsLabel.styleClass = "tab_active"; }');

```

But i’m still getting the same error!

Regards,  
Hareendra

---

<div class="post-metadata">

**Author:** ![jdbruijn](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@jdbruijn](https://forum.servoy.com/u/jdbruijn)\
**Post date:** [August 26, 2014, 7:08am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/4 "2014-08-26T07:08:08Z")

</div>

My guess is that the error is related to the first line of the code you originally posted, so this line should be at the top of this code:

```auto
history.removeForm(sform);
jsLabel = jsform.newLabel(row[0], (2 + ((index-1) * 122)), 10, 120, 20);

```

Maybe it is a good idea for you to have a good look at the documentation of the Solution Model  
[https://wiki.servoy.com/display/DOCS/Solution+Model](https://wiki.servoy.com/display/DOCS/Solution+Model)  
or these video’s

[![](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/6/60207b482b789a02ccb4665cc23f5d50e12a66ae.webp "ServoyCamp 2011: SolutionModel from Scratch Part 1 - Vincent Schuurhof (Servoy)") ](https://vimeo.com/34899800)

[![](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/3/393bfcc71346f7e1d6c5c513cfb9313734e70e4f.webp "ServoyCamp 2011: SolutionModel from Scratch Part2 - Vincent Schuurhof (Servoy)") ](https://vimeo.com/34900356)

---

<div class="post-metadata">

**Author:** ![sovanm](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@sovanm](https://forum.servoy.com/u/sovanm)\
**Post date:** [August 26, 2014, 7:13am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/5 "2014-08-26T07:13:20Z")

</div>

Hi,

This error comes up when you try to modify the blueprint of the form and try to load the form when it is already loaded.

If we need to show the modified blue print, then we need to call the recreateUI of the controller as last line after modifying the content.

> forms[jsForm.getName()].controller.recreateUI();

Even you can also remove the history before modifying and loading the form again as Jos suggested.

But, what this line trying to do ?

> forms.frm\_navigation\_bar.jsLabel.styleClass = “tab\_active”;

Here jsLabel is the actual form component or the label created via solution Model?

---

<div class="post-metadata">

**Author:** ![hareendra](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@hareendra](https://forum.servoy.com/u/hareendra)\
**Post date:** [August 26, 2014, 8:18am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/6 "2014-08-26T08:18:17Z")

</div>

Hi,  
yes, jsLabel is the label created via the solution model.

---

<div class="post-metadata">

**Author:** ![jdbruijn](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@jdbruijn](https://forum.servoy.com/u/jdbruijn)\
**Post date:** [August 26, 2014, 8:42am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/7 "2014-08-26T08:42:56Z")

</div>

you cannot use it like that. You have to use the element name:

```auto
forms.frm_navigation_bar.elements['myLabel'].styleClass = "tab_active";

```

where myLabel is the name of the jsLabel you created with the solution model.

But reading your original post a little better, why are you creating a method for each label you create?  
Why not create a single function in your frm\_navigation\_bar that handles the activation of the correct label?  
something like this:

```auto
/**
 * form variable to hold the current active label
 *@type{String}
 */
var active_lbl = '';

/**
 * function to toggle the active tab
 * @param {JSEvent} event
 */
function onToggleTab(event){
  // first deactivate the current active tab
  elements[active_lbl].styleClass = 'tab_inactive';
  active_lbl = event.getElementName();
  elements[active_lbl].styleClass = 'tab_active';
}

```

and your function would look something like this:

```auto
  var jsMethod = jsForm.getMethod('onToggleTab');
  var jsLabel = jsform.newLabel(row[0], (2 + ((index-1) * 122)), 10, 120, 20, jsMethod);
      jsLabel.styleClass = 'tab_inactive';
       jsLabel.showClick = false;

```

---

<div class="post-metadata">

**Author:** ![hareendra](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@hareendra](https://forum.servoy.com/u/hareendra)\
**Post date:** [August 26, 2014, 9:32am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/8 "2014-08-26T09:32:09Z")

</div>

Hi,  
One problem is that elements do not have a styleClass property.  
Regards,  
Hareendra

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [August 26, 2014, 9:35am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/9 "2014-08-26T09:35:59Z")

</div>

Hi Hareendra,

styleClass is not a runtime property. You can set it using the solutionModel.

---

<div class="post-metadata">

**Author:** ![jdbruijn](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@jdbruijn](https://forum.servoy.com/u/jdbruijn)\
**Post date:** [August 26, 2014, 11:36am UTC](https://forum.servoy.com/t/solution-model-getting-stale-form-s-detected/18137/10 "2014-08-26T11:36:37Z")

</div>

> ROCLASI:  
> styleClass is not a runtime property. You can set it using the solutionModel.

ah yes I forgot about that.

You can also create 2 labels on top of each other and hide/show the correct label.
