Solution Model Getting Stale form(s) detected

Questions and answers for designing and implementing forms in Servoy

Solution Model Getting Stale form(s) detected

Postby hareendra » Tue Aug 26, 2014 6:32 am

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.
Code: Select all
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
hareendra
 
Posts: 98
Joined: Wed Sep 17, 2008 11:41 am

Re: Solution Model Getting Stale form(s) detected

Postby jdbruijn » Tue Aug 26, 2014 8:37 am

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:
Code: Select all
history.removeForm(formName)
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Solution Model Getting Stale form(s) detected

Postby hareendra » Tue Aug 26, 2014 8:54 am

Hi,

I tried the following,
Code: Select all
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
hareendra
 
Posts: 98
Joined: Wed Sep 17, 2008 11:41 am

Re: Solution Model Getting Stale form(s) detected

Postby jdbruijn » Tue Aug 26, 2014 9:08 am

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:
Code: Select all
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
or these video's
http://vimeo.com/34899800
http://vimeo.com/34900356
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Solution Model Getting Stale form(s) detected

Postby sovanm » Tue Aug 26, 2014 9:13 am

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?
sovanm
 
Posts: 99
Joined: Fri Oct 28, 2011 1:55 pm
Location: Bhubaneswar, India

Re: Solution Model Getting Stale form(s) detected

Postby hareendra » Tue Aug 26, 2014 10:18 am

Hi,
yes, jsLabel is the label created via the solution model.
hareendra
 
Posts: 98
Joined: Wed Sep 17, 2008 11:41 am

Re: Solution Model Getting Stale form(s) detected

Postby jdbruijn » Tue Aug 26, 2014 10:42 am

you cannot use it like that. You have to use the element name:
Code: Select all
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:
Code: Select all
/**
* 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:
Code: Select all
  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;
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Solution Model Getting Stale form(s) detected

Postby hareendra » Tue Aug 26, 2014 11:32 am

Hi,
One problem is that elements do not have a styleClass property.
Regards,
Hareendra
hareendra
 
Posts: 98
Joined: Wed Sep 17, 2008 11:41 am

Re: Solution Model Getting Stale form(s) detected

Postby ROCLASI » Tue Aug 26, 2014 11:35 am

Hi Hareendra,

styleClass is not a runtime property. You can set it using the solutionModel.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Solution Model Getting Stale form(s) detected

Postby jdbruijn » Tue Aug 26, 2014 1:36 pm

ROCLASI wrote: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.
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm


Return to Forms

Who is online

Users browsing this forum: No registered users and 5 guests