Hi,

here

http://www.pow2.com/download/dbforms_src_20021125.zip

there is a zip archive with my source tree containing the work related to the support of pluggable event classes for the event engine.

A brief explanation.

The pluggable event system should make possible to:

a) for all the event types, declare the event class(es) related to a certain event type using a declarative configuration via the dbforms-config.xml file

b) for every table defined into the dbforms-config.xml file, get the possibility to override the event class related to a certain event type.

c) let configure event class properties via the dbforms-config.xml file


I'm finishing the point (a).
In attachment there's my event configuration.
It's possible to configure:

- database events
- insert
- update
- update (keyInfo)
- delete
- delete (keyInfo)

- navigation events
- first
- prev
- next
- last
- new
- goto

See the following declaration:

<database-event param="ac_insert" className="org.dbforms.event.InsertEvent" />

param
specifies the parameter that identifies the event type;

className
specifies the full qualified class name of the event class related to that parameter (and so, to the event type)

there is another hidden parameter: "id"
id should be an unique event identifier used to define more than an event class for a certain event type.
The table elements then could use that id to override the event class related to a certain event type.

Anyway, there is a problem.... the disposable event TYPEs are "defined" into two classes:

- event/EventEngine
- taglib/DbFormTag

In the EventEngine class, the following strings defines the event types:

- ac_insert
- ac_update
- ac_updatear
- ac_delete
- ac_deletear
- ac_first
- ac_prev
- ac_next
- ac_last
- ac_new
- ac_goto

In the DbFormTag, there are other stings instead:

- navFirst
- navPrev
- navNext
- navLast
- navNew
- goto


I propose to define somewhere the disposable database / navigation event types:

- insert
- update
- update (keyInfo)
- delete
- delete (keyInfo)
- navigation first
- navigation prev
- navigation next
- navigation last
- navigation new
- navigation goto

then, for every event type, define the strings that identify it, to keep the compatibility with the current code.

So we could define an event using (for example):

<database-event type="insert" className="org.dbforms.event.InsertEvent" />

without repeating event declarations as done in the attached text, where there is a config for the event engine and another one for the dbforms tag class.

Now we could add the id attribute to define more than one event class for an event type:

<database-event type="insert" className="org.dbforms.event.InsertEvent1" />
<database-event id="ins2" type="insert" className="org.dbforms.event.InsertEvent2" />

here we define two events: a default one without id and another one with id = "ins2". They are related to different event classes.

As said above, the id attribute could be used into table elements to decide the event class to use for a certain event type:

<table name="MYTABLE">
<field name="MYFIELD" fieldType="date"/>
...

<interceptor className="foo.bar.interceptor.MyInterceptor"/>

<events>
<database-events>
<database-event id="ins2" />
<database-event id="updateView">
<param name="sourceView" value="myView">
<param name="targetTable" value="myTable">
</database-event>
<database-events>
<events>

</table>

and every event class can be configured using parameters...

Any suggestion / idea ?

Regards,
Luca

<?xml version="1.0" encoding="ISO-8859-1" ?>

<dbforms-config>

 ...

 <!--
    -  Events configuration
    -->
 <events>

   <database-events>
     <!-- database-event id="ac_insert"   param="ac_insert_"   
className="org.dbforms.event.InsertEvent" /-->
     <database-event param="ac_insert"   className="org.dbforms.event.InsertEvent" />
     <database-event param="ac_update"   className="org.dbforms.event.UpdateEvent" />
     <database-event param="ac_updatear" className="org.dbforms.event.UpdateEvent" />
     <database-event param="ac_delete"   className="org.dbforms.event.DeleteEvent" />
     <database-event param="ac_deletear" className="org.dbforms.event.DeleteEvent" />
   </database-events>

   <navigation-events>

     <!-- config for the event engine -->
     <navigation-event param="ac_first" className="org.dbforms.event.NavFirstEvent" />
     <navigation-event param="ac_prev"  className="org.dbforms.event.NavPrevEvent"  />
     <navigation-event param="ac_next"  
className="org.dbforms.event.BoundedNavNextEventImpl"  />
     <navigation-event param="ac_last"  
className="org.dbforms.event.BoundedNavPrevEventImpl"  />
     <navigation-event param="ac_new"   className="org.dbforms.event.NavNewEvent"   />
     <navigation-event param="ac_goto"  className="org.dbforms.event.GotoEvent"     />

         <!-- config for DbFormTag local events (must repeat...) -->
     <navigation-event param="navFirst" className="org.dbforms.event.NavFirstEvent" />
     <navigation-event param="navPrev"  className="org.dbforms.event.NavPrevEvent"  />
     <navigation-event param="navNext"  
className="org.dbforms.event.BoundedNavNextEventImpl"  />
     <navigation-event param="navLast"  
className="org.dbforms.event.BoundedNavPrevEventImpl"  />
     <navigation-event param="navNew"   className="org.dbforms.event.NavNewEvent"   />

   </navigation-events>

 </events>

</dbforms-config>

Reply via email to