Calling servoy functions from a bean

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…

var _nRecCount = databaseManager.getFoundSetCount(foundset);

from with my bean.

Thanks,
Larry Long

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,

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!

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)

Pat,

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

Larry