KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Executing Component Methods on 4D Server
PRODUCT: 4D Server | VERSION: 11.4 | PLATFORM: Mac & Win
Published On: June 24, 2009
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

There are a couple of different ways to execture your component method on 4D Server. If you have the component method called directly in the Host database then it works the same way that methods in the Host database do, call EXECUTE ON SERVER and execute the component method.

On the other hand, if you are calling the component method from inside the component (via another component method) there are two different ways to handle the situation:

  1. Call EXECUTE ON SERVER in the component method and pass the second component method as a the process method parameter.
  2. Set the method properties to "Execute on Server"

For example your component could have two methods: MC_execute_on_server and MC_Method1. In your host database you want to call MC_Method1 and MC_Method1 calls the MC_execute_on_server method, which should be executed on 4D Server.

Here is the MC_execute_on_server method:

` MC_execute_on_server method
` brings up an alert on 4D Server

ALERT("Hello ON SERVER from my component!")


If you choose option 1 from the above list, the code for MC_Method1 would look like this:

C_LONGINT($proc)
$proc:=Execute on server("MC_execute_on_server";128000;"server_proc_from_component")


In this case make sure that you have the MC_execute_on_server method set as "Shared by Components and Host Database" in its Method Properties.

If you would like to use option 2, and avoid the "Shared by Components and Host Database" setting for MC_execute_on_server, you can instead use the Method Property "Execute on Server". In that case the MC_Method1 would just look like this:

MC_execute_on_server


This second method is much simpler, but in this case the MC_execute_on_server method will always be executed on the server. It also allows you to hide the MC_execute_on_server method, not sharing the method between the component and the host.


Commented by Tim Penner on July 15, 2009 at 4:59 PM
Here is a Tech Note that discusses the new Execute On Server method property: http://kb.4d.com/search/assetid=75177