4D v16

ホストデータベースイベント

ホーム

 
4D v16
ホストデータベースイベント

ホストデータベースイベント    


 

 

4D v14 ではDatabase Events 定数テーマ内に新しいホストデータベースイベントが追加されています。

There are new events available in the Database Events:
On after host database exit    
On after host database startup
On before host database exit
On before host database startup   

These events can hand over control to the component we created even before the On Startup or On Exit methods are run on the database where this component is located.

Let’s take a quick look at the structure. We have our database and the component folder where our component is located. We’re going to change the component to add the four events concerned. In Methods, Database Methods => On Host Database Method, we’ll copy the code shown in the documentation; this means the 4 events are visible here, and we use the method we created in the component while indicating just the event that is running.

So these events can be used, for example, to initialize variables, retrieve files, check for an indicator or file, before opening, after opening, before closing or after closing, or maybe to update files for instance. Let's close the component again.

Now, in the database methods for the host database, we’re going to add a couple of things:
•    In the On Startup method, we add an alert using the alert of the component to indicate that the host database is being opened
•    And in the On Exit database method, we’ll also indicate that the host database is being closed.

Now if we exit and launch the first database again, we can see the “on startup” event and also the “on exit” event when we close it, but there’s no trace of these events that we indicated in the component. Why not? It’s a question of security. If we want to run component events, it is mandatory to check the box allowing the On Host Database Event method of the components to be executed, found on the Security page of the Database Settings.

So it is actually the host database that allows components to run the methods in question. We need to close and open the database again to see it work. So now we have the “on before startup” event of the component that runs, “on startup” of the host database, “on after host database startup” and then when we exit, “on before exit” of the component, even though it says “host database” it’s the event in question so it’s actually “on before exit” of the component, “on exit” of the host database, then “on after exit” of the component.

 
 

 
プロパティ 

プロダクト: 4D
テーマ: ホストデータベースイベント

 
履歴 

初出: 4D v14

 
ARTICLE USAGE

セルフトレーニング ( 4D v16)