getMehodTriggerElementName & getMethodTriggerFormName issue

Questions and answers regarding the use of eclipse environment as seen in Servoy Developer

getMehodTriggerElementName & getMethodTriggerFormName issue

Postby Roberto Blasco » Sun Dec 13, 2009 10:59 pm

Hello everybody.

In Servoy developer 5.0 the following methods

- application.getMethodTriggerElementName()
- application.getMethodTriggerFormName()

does not appear in the jscript editor writing application. + ctrl + space, but it works if I write the whole sentence.

Does anybody notice this issue?
Un saludo. Roberto.

Madrid - Spain
Tfno: (+34) 625653066
E-mail: roberto.blasco.serrano@gmail.com
User avatar
Roberto Blasco
007
 
Posts: 355
Joined: Tue Apr 08, 2008 7:18 pm
Location: Madrid / Spain

Re: getMehodTriggerElementName & getMethodTriggerFormName issue

Postby ptalbot » Sun Dec 13, 2009 11:05 pm

These methods have been deprecated in Servoy 5 (meaning they still work but are not recommanded to use anymore), from now on you should use the JSEvent equivalent methods:

Code: Select all
function eventMethod(event) {
    var frm = event.getFormName();
    var elem = event.getElementName();
    ....
}
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: getMehodTriggerElementName & getMethodTriggerFormName issue

Postby ROCLASI » Sun Dec 13, 2009 11:10 pm

Hi Roberto,

These methods are deprecated in 5.0. Which means they stil work but will be fased out over time.
When a method is called from any (form/button/field) event it will get a JSEvent object passed that will have the following (among others) functions:
event.getElementName()
event.getFormName()

You are encouraged to use this new way of coding.

Hope this helps.
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: getMehodTriggerElementName & getMethodTriggerFormName issue

Postby ROCLASI » Sun Dec 13, 2009 11:10 pm

Seems Patrick was faster on the reply button. ;)
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: getMehodTriggerElementName & getMethodTriggerFormName issue

Postby Roberto Blasco » Sun Dec 13, 2009 11:15 pm

Thanks for the reply.
Un saludo. Roberto.

Madrid - Spain
Tfno: (+34) 625653066
E-mail: roberto.blasco.serrano@gmail.com
User avatar
Roberto Blasco
007
 
Posts: 355
Joined: Tue Apr 08, 2008 7:18 pm
Location: Madrid / Spain

Re: getMehodTriggerElementName & getMethodTriggerFormName is

Postby xtsr » Wed Mar 28, 2012 8:18 pm

After upgrading from 4.1 to 6 I had fixed all the warnings I had for using these deprecated functions. I use the proposed method, however, it does not work in all cases. I'm probably missing something here.

In my onShow script I call a method that hides certain elements on a form. It's a global method that needs to know by which form it was called.
Code: Select all
/**
* @properties={typeid:24,uuid:"902CF6D6-5F08-4375-8284-BE6ACBF83A7A"}
* @param {JSEvent} event
*/
function onShow(event)
{
   globals.gmd_hideSearchBtns(null, event);
...


Method to hide buttons:
Code: Select all
/**
* @properties={typeid:24,uuid:"C89FE07F-019F-445F-BD19-B8F534E7374A"}
* @param {String} frmName
* @param {JSEvent} event
*/
function gmd_hideSearchBtns(frmName, event)
{
    if ( !frmName ) {
      frmName = event.getFormName();
...


While getMethodTriggerFormName returns the correct form, event.getFormName() does not. The Interactive Control shows:
=>event
true
=>application.getMethodTriggerFormName()
"tab_obj_bp"


I have the same problem, when I use search/find
Code: Select all
/**
* @properties={typeid:24,uuid:"E9D5235E-9542-490D-B10E-F7FDD4A541A8"}
* @param {JSEvent} event
*/
function onFind(event)
{
   globals.gmd_saveFoundset('tab_obj_bp');
   globals.gmd_showSearchBtns(null, event);
   controller.find();
}

/**
* @properties={typeid:24,uuid:"F884FAF1-CA24-4C0E-B6BC-BA9F99C18E49"}
* @AllowToRunInFind
* @param {JSEvent} event
*/
function onSearch(event)
{
   globals.gmd_onSearch(null, event);
   controller.search();
}


OnFind works (event has all the info), hitting enter to do onSearch just gives me event = true.

Can I change something that lets me use event.getFormName?

If that does not work, I can of course send the the form name in the frmName parameter or use a global variable, which I could set in the onShow method. I previously did not do that, since application.getMethodTriggerFormName() worked and I only needed the parameter for overrides.

Thanks,
Reto
xtsr
 
Posts: 101
Joined: Wed Jan 21, 2004 11:47 am

Re: getMehodTriggerElementName & getMethodTriggerFormName is

Postby jbrancoIF » Thu Mar 29, 2012 10:14 am

Hi Reto,

You missed a parameter in the onShow, that's the new declaration:

Code: Select all
/**
* Callback method for when form is shown.
*
* @param {Boolean} firstShow form is shown first time after load
* @param {JSEvent} event the event that triggered the action
*
* @properties={typeid:24,uuid:"BC03F225-5991-4B93-B280-6126F856883D"}
*/
function onShow(firstShow, event) {


The same for onFind and onSearch. Just create a new form in 6 and make Servoy generate all methods automatically for you so you can see the parameters.
João
InfoForm SA

Servoy 2021.03
jbrancoIF
 
Posts: 68
Joined: Tue Jan 10, 2012 11:29 am

Re: getMehodTriggerElementName & getMethodTriggerFormName is

Postby xtsr » Thu Mar 29, 2012 2:48 pm

Thanks, works perfectly! The upgrade to Servoy 6 requires quite a lot of effort, but so far I'm very impressed by the improvements. Great work :-) No doubt that I'll have to ask more questions, though...
xtsr
 
Posts: 101
Joined: Wed Jan 21, 2004 11:47 am


Return to Eclipse Environment

Who is online

Users browsing this forum: No registered users and 9 guests