Page 1 of 1

jsMethod not fired in find mode

PostPosted: Fri Dec 02, 2011 10:34 am
by irenem
Hello,

My onFind method creates a button with a method, but it doesn't work in find mode.

Code: Select all
   
   var form = controller.getName()
   var frm = solutionModel.getForm(form)
   var ofgMeth = solutionModel.newGlobalMethod('function totRec(event){var source = event.getElementName();globals.g_search = source}')
        var x = frm.newButton('button',0,0,20,20,ofgMeth)
        x.name = 'button'
   forms[form].controller.recreateUI()
        controller.find()


If I remove controller.find() it works.

Re: jsMethod not fired in find mode

PostPosted: Fri Dec 02, 2011 1:19 pm
by mboegem
did you include something like:
Code: Select all
if(false) controller.search()


in your search method?
Otherwise a method won't be triggered in find mode.

Re: jsMethod not fired in find mode

PostPosted: Fri Dec 02, 2011 1:33 pm
by ngervasi
In Servoy 6 you don't need that anymore, there is a JSDoc property to allow method execution in Find mode, it's called @AllowToRunInFind, check the docs to know more about it.

Re: jsMethod not fired in find mode

PostPosted: Fri Dec 02, 2011 2:57 pm
by mboegem
thnkx Nicola!

with all the nice new features in 6, it's easy to forget some. :-)

Re: jsMethod not fired in find mode

PostPosted: Fri Dec 02, 2011 4:06 pm
by irenem
Thank you Nicola,

I will try to find out how it works. I just read the wiki, it's a bit of a jungle. :shock:

Re: jsMethod not fired in find mode

PostPosted: Sat Dec 03, 2011 12:23 pm
by irenem
Ok, @AllowToRunInFind is added, but it still doesn't work. Could it that it doesn't apply for the solutionModel?

Code: Select all
/**
* @AllowToRunInFind
*
* @properties={typeid:24,uuid:"D4C3C1A6-4266-480F-969A-16B7FDCA3E39"}
*
*/
function onFind()
{
   controller.find()
   var form = controller.getName()
   var frm = solutionModel.getForm(form)
   var ofgMeth = solutionModel.newGlobalMethod('function totRec(event){var source = event.getElementName();globals.g_search = source}')
        var x = frm.newButton('button',0,0,20,20,ofgMeth)
        x.name = 'button'
   forms[form].controller.recreateUI()

}

Re: jsMethod not fired in find mode

PostPosted: Sun Dec 04, 2011 11:50 am
by mboegem
Irene, it's the 'ofgMeth' function that should be allowed to run in find mode.

The 'onFind' function will run whenever your solution is still in browse mode.