Calling servoy functions from a bean

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Calling servoy functions from a bean

Postby lalong » Thu Sep 29, 2011 12:17 am

Is there a way to reference servoy functions from within a java bean that I am creating?
For example, if I want to do the equivalent of...
Code: Select all
var _nRecCount = databaseManager.getFoundSetCount(foundset);

from with my bean.

Thanks,
Larry Long
lalong
 
Posts: 40
Joined: Thu Aug 05, 2010 1:42 pm

Re: Calling servoy functions from a bean

Postby ptalbot » Thu Sep 29, 2011 7:13 pm

Hi Larry,

you can access an IFoundSet in your bean by implementing the IServoyAwareBean interface, you will receive the current record within the setSelectedRecord method, then get access to its foundset using IRecord.getParentFoundSet() (or getRelatedFoundSet if it is related).

Also if you have implemented an IServoyBeanFactory, you will be asked for the implementation of you bean from the getBeanInstance() method, which will receive an instance of IClientPluginAccess which has (among other interesting things) a getDatabaseManager() method giving you access to an IDatabaseManager object.

Have a look at the Servoy API http://www.servoy.com/docs/public-api/ for what you can do with these different interfaces...

Hope this helps,
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: Calling servoy functions from a bean

Postby lalong » Mon Oct 03, 2011 1:53 pm

I've looked at the IDatabaseManager and it only has a very limited number of methods available (at least according to the current docs). As mentioned before, I was specifically looking to be able to call the getFoundSetCount method (or an equivalent) that is in the DatabaseManager runtime API, so I can do some calculations for a bean.

Better yet, is there a way to pass a function call from the java code in a bean to the servoy runtime api or raise an event that the js runtime can pickup?

Thanks,
Larry Long

p.s. Hold on. I see perhaps how and where I can to this from the IClientPluginAccess...stay tuned!
Last edited by lalong on Mon Oct 03, 2011 2:30 pm, edited 1 time in total.
lalong
 
Posts: 40
Joined: Thu Aug 05, 2010 1:42 pm

Re: Calling servoy functions from a bean

Postby ptalbot » Mon Oct 03, 2011 2:26 pm

I suppose the IDatabaseManager has just the right amount of methods. I never had to call a getFoundsetCount on a foundset, getSize generally is enough.

To call a method from a plugin or bean, have a look at IClientPluginAccess.executeMethod or FunctionDefinition.execute (the last one, I just realized is deprecated in Servoy 6 (!) so FunctionDefinition.executeAsync or FunctionDefinition.executeSync)
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: Calling servoy functions from a bean

Postby lalong » Mon Oct 03, 2011 2:32 pm

Pat,

You're too quick for me! I just edited my previous posting, before I saw your response.

Larry
lalong
 
Posts: 40
Joined: Thu Aug 05, 2010 1:42 pm


Return to How To

Who is online

Users browsing this forum: No registered users and 11 guests