newFormMethod using pointer

Discuss all feature requests you have for a new Servoy versions here. Make sure to be clear about what you want, provide an example and indicate how important the feature is for you

newFormMethod using pointer

Postby martinh » Tue Nov 23, 2010 2:32 pm

Hi,

I would like to know if the following is realistic for a future release.
Using the SolutionModel you can create methods on forms. For example like this:

Code: Select all
var frmA = solutionModel.getForm('myFormA')
var frmB = solutionModel.getForm('myFormB')         

var   _all_methods =    frmA.getFormMethods()
var _methodName, _methodA, _methodB

for (var m = 0; m < _all_methods.length; m++)
{
   _methodName = _all_methods[m].getName()

   _methodA = _all_methods[m];
   if (! frmB.getFormMethod(_methodName)) // Check if method exists
   {
      //   Method doesn't exists on form B, so add it now
      _methodB = frmB.newFormMethod(_methodA.code)
   }
}


I want to copy some methods on form A to form B (in the example all methods are copied). This is only a small part of the coding I use.
Using 'extendsForm' is not a solution in my case. And creating all global methods isn't either.
The above works correctly.
The problem is that when I debug, that the method on form B is executed, but you can't step through it using the debugger.

What I would like to have, is that I can use a pointer to a method, like this:

Code: Select all
      _methodB = frmB.newFormMethod(_methodA) // _methodA is a JSMethod object


And since this is a pointer, the debugger can step into this coding, because it points to coding that was made on designtime.

Could this be an option for a future release?

Martin
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: newFormMethod using pointer

Postby mboegem » Tue Nov 23, 2010 4:53 pm

Hi Martin,

If I understand you correctly you have 2 forms: 'A' & 'B'
form A contains methods that you want to copy to form B (if non existant)
Once you've done that, you expect your solution to work with the methods of form B.

I don't know why the above shouldn't work in the current release?
If you make the correct call to your new methods then it should work just fine.

In case of trigger by event (ie onShow), make sure you attach the new method to this event.

Hope this helps.
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: newFormMethod using pointer

Postby martinh » Tue Nov 23, 2010 5:14 pm

Hi Marc,

It does work, but I can't debug it, because this coding was not written on designtime.
Also this means that in memory I have those methods twice, one time for form A and one time for form B

For example I have the global method onShow defined on both form A and B and I have onMyShow defined only on form A and I want to call this method on form A also onShow of form B (form A and B have/share the same foundset)

Code: Select all
function global_method_onShow()
{
   var _first_show = arguments[0]
   var _event = arguments[1]
   
   var _form = _event.getFormName();
   
   if (forms[_form].onMyShow)
   {
      forms[_form].onMyShow(_first_show, _form);    // Now this works fine on form A and also if the method is designed for form B
   }
   else if (forms['formA'].onMyShow)    // Now in case form B triggers the event
                              // Check if the onMyShow is designed on form A
      {
         forms['formA'].onMyShow(_first_show, _form);
                                 //So now I call the onMyShow() method on form A, while
                                 // my current form is form B
                                 // So I don't have to design all methods on both form A and form B
                                 // But I have to check twice if a method is on form A and/or on form B
      }
}


So when I create using the SolutionModel onMyShow() on form B, then it works, but I can't debug it (in the above example I can debug it)
I thought that when I could create a newFormMethod using a pointer to an existing method in stead of recreate the same method, that
maybe I can debug this coding and also I don't waste memory by keeping both methods (which are equal) in memory.
This is not 1 form I want the handle like this, but hunderds.

That's why I proposed this possibility. So it is not a bug.

Martin
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: newFormMethod using pointer

Postby mboegem » Tue Nov 23, 2010 6:10 pm

ok, got your point then.

We ran into the same issue before inheritance of forms even existed.
How did we solve it?

We have different so called 'programs' in our solution.
Each program has 1 masterform, called [ProgramName]_methods.
These forms contain methods specifically to that program and we use them as sort of substitute to global methods.
Then from the individual forms, let's say [ProgramName]_detail or [ProgramName]_list we call the methods on the 'method' form of this specific module.

As we have forminheritance nowadays, I'd like to cleanup the above structure where possible... but there's other priorities to concentrate on first :-)

Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: newFormMethod using pointer

Postby martinh » Tue Nov 23, 2010 6:14 pm

Hi Marc,

I'm familiar with this 'programs' setup.
I made this setup 3,5 years ago when I made my servoy framework.
But now I want to reduce the script in my framework and use more of the functionality of Servoy.

So therefore I think it can be useful if newFormMethod() can accept an existing method as parameter.

This would make it perfect. :)

Martin
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: newFormMethod using pointer

Postby mboegem » Tue Nov 23, 2010 10:55 pm

martinh wrote:So therefore I think it can be useful if newFormMethod() can accept an existing method as parameter.


Guess there's only one way to find out if Servoy finds it useful as well: file a feature request...
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: newFormMethod using pointer

Postby jcompagner » Mon Nov 29, 2010 12:49 pm

martinh wrote:
So therefore I think it can be useful if newFormMethod() can accept an existing method as parameter.

This would make it perfect. :)



This is not possible the same way you can't do that in the designer itself..
There you also can't just point to another forms method. So before we could support the above we also have to rewrite how the designer works (also there you should be able to call any form method from any form event)

The thing is what do you expect that the context is in for that method? What is the foundset variable inside that method? Should that be the foundset of B (the copy) or from A (the source)?

The only thing now to do it is using inheritance. Have a (abstract) form with methods that you inherit then you can use all those methods in the solution model created subform.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Discuss Feature Requests

Who is online

Users browsing this forum: No registered users and 10 guests