namedFoundSet in SolutionModel

Questions, tips and tricks and techniques for scripting in Servoy

namedFoundSet in SolutionModel

Postby irenem » Wed Sep 08, 2010 12:01 pm

FormA has tab panel1 that contains form1 and tab panel 2 that contains form 2. All forms have the same data source.
I want form1 and form2 both with separate found sets.
Code: Select all
var formCal1 = solutionModel.newForm('cal1', 'coperta', 'actions', null, true, 240, 35);
   var headerCal1 = formCal1.newHeaderPart(20)
   formCal1.navigator = SM_DEFAULTS.NONE;
   formCal1.scrollbars = SM_SCROLLBAR.HORIZONTAL_SCROLLBAR_NEVER|SM_SCROLLBAR.VERTICAL_SCROLLBAR_NEVER;
   formCal1.borderType = 'EmptyBorder,0,0,0,0'
   formCal1.styleName = 'coperta';
   formCal1.styleClass = 'toolbar';
   formCal1.transparent = true;
   formCal1.view = JSForm.LIST_VIEW

   formCal1.onLoad = formCal1.newFormMethod('function onShow() {var frm = currentcontroller.getName();forms["cal1"].controller.loadAllRecords();var query = "SELECT usr_id FROM users WHERE usr_cal_user =1";var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), query, null, 100); var vdataset = dataset; var row = new Array();forms["cal1"].controller.find(); var rangeX = "#" + globals.g_search_day_1 + "|dd-MM-yyyy"; var first = vdataset.getValue(1, 1); forms["cal1"].act_user_id = first; forms["cal1"].act_date_begin = rangeX; forms["cal1"].act_type = "2"; for(var i = 2 ; i <= dataset.getMaxRowIndex() ; i++ ){row[i] = vdataset.getValue(i, 1); forms["cal1"].controller.newRecord(); forms["cal1"].act_user_id = row[i]; forms["cal1"].act_date_begin = rangeX; forms["cal1"].act_type = "2";}forms["cal1"].controller.search();}')   

   var myFoundSet1 = forms['cal1'].foundset;
   //formCal1.namedFoundSet = myFoundSet1;


As soon as I call "formCal1.namedFoundSet = myFoundSet1;" it comes with a "Stale form error"

Thanks for any help
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: namedFoundSet in SolutionModel

Postby victor.rojo » Wed Sep 08, 2010 12:33 pm

I think that the namedFoundSet property only tells if the foundset is separate, not what foundset is used in the form. Did you try formCal1.namedFoundSet = "separate"?
Best regards/Un saludo,

Victor Rojo
Developer

NeoCursar, S.L. - Developers Team
--
Servoy 5.2.8 - build 1016 / Version: 6.0.2 - build 1222
Mac OS X 10.7
victor.rojo
 
Posts: 74
Joined: Mon Jan 11, 2010 1:49 pm

Re: namedFoundSet in SolutionModel

Postby irenem » Wed Sep 08, 2010 12:42 pm

Hello Victor,

Did you try formCal1.namedFoundSet = "separate"?


Yes I've tried that, but it doesn't work.

According the sample that comes with the method it is necessary to define a found set first an then give the name to the property.

Code: Select all
var firstForm = solutionModel.newForm('newForm1', 'myServer', 'myTable', null, true, 800, 600);
   var secondForm = solutionModel.newForm('newForm2', 'myServer', 'myTable', null, true, 800, 600);
   forms['newForm2'].controller.find()
   forms['newForm2'].columnTextDataProvider = '=aSearchValue';
   forms['newForm2'].controller.search()
   var myFoundSet = forms['newForm2'].foundset
   firstForm.namedFoundSet = myFoundSet;   


The mistake must be somewhere else... no idea where :(
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: namedFoundSet in SolutionModel

Postby victor.rojo » Wed Sep 08, 2010 12:56 pm

Seeing the wiki http://wiki.servoy.com/display/public/DOCS/JSForm#JSForm-namedFoundSet :

Property that tells the form to use a named foundset instead of the default foundset.
When "separate" as special value is specified the form will always create a copy of assigned foundset and therefor become separated from other foundsets


and in the property tooltip info in the developer:

String namedFoundSet Property that tells the form to use a named foundset instead of the default foundset. Currently only "separate" can be specified as value, meaning that the form will use a separate foundset.


I think that the sample is wrong... Can any Servoyan confirm this?
Best regards/Un saludo,

Victor Rojo
Developer

NeoCursar, S.L. - Developers Team
--
Servoy 5.2.8 - build 1016 / Version: 6.0.2 - build 1222
Mac OS X 10.7
victor.rojo
 
Posts: 74
Joined: Mon Jan 11, 2010 1:49 pm

Re: namedFoundSet in SolutionModel

Postby irenem » Wed Sep 08, 2010 1:07 pm

This is right for a physical form but my forms are designed with the SolutionModel.

If I try formCal1.namedFoundSet = "separate" it returns the same "Stale form" error and if I try separate without quotes it complains that separate is not defined.

I wish it were just so simple.
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: namedFoundSet in SolutionModel

Postby mboegem » Wed Sep 08, 2010 1:46 pm

That's because you call ' var myFoundSet1 = forms['cal1'].foundset;'
Asking for the foundset of a form simply loads the form in memory.
After that you're trying to alter the form again by setting the 'namedFoundset' property.

As for the namedFoundset property: as far as I know the solutionModel can not handle any other settings than the normal form properties.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: namedFoundSet in SolutionModel

Postby irenem » Wed Sep 08, 2010 2:05 pm

Hello Marc,

Thanks for the explanation.

But how can I tell to the form to use a different found set If I have made it with the SolutionModel?
With the physical Form you just put "separate in the property an the trick is done. But the Solution Model doesn't allow that.
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: namedFoundSet in SolutionModel

Postby mboegem » Wed Sep 08, 2010 2:37 pm

based on a designtime form I'd say: jsForm.namedFoundSet = 'separate' should do the job.
after that you can load just any foundset you want, without this forms foundset will alter another foundset based on the same table.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: namedFoundSet in SolutionModel

Postby irenem » Wed Sep 08, 2010 2:45 pm

I wish.... as I already wrote:

If I try formCal1.namedFoundSet = "separate" it returns the same "Stale form" error and if I try separate without quotes it complains that separate is not defined.

I wish it were just so simple.


Thats why I don't get it, in the physical forms is so simple... may be a bug?
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: namedFoundSet in SolutionModel

Postby mboegem » Wed Sep 08, 2010 2:56 pm

the "Stale form" error is thrown when you alter a form that's already in memory.

when you reference 'forms['justAnyFormName']' this form is being loaded into memory.
After that no alterations can be made to that form using the solutionModel as they will result in the "Stale form" error

So: move/delete the line where you reference 'forms['cal1'].foundset' (Based on your first post I'd say it has no use anymore) and you're set.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: namedFoundSet in SolutionModel

Postby irenem » Wed Sep 08, 2010 3:52 pm

Yeah, I forgot that. Now it works

Thank you.
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 5 guests

cron