Hi all !
Henner Kollmann wrote:
> I would prefer an other solution. Don't know if it would be possible. No
> idea how to implement....
> Something in the dbforms-config.xml like:
>
> <table name="alarmwebprotokoll">
> <insert_sql>
> insert into .....
> </insert_sql>
> <update_sql>
> update ...
> </update_sql>
> </table>
>
> All fields found in the insert/update sql should be filled with values
> from the table.
> So the numer of fields in table could be different to the numbers of
> fields in insert/update.
>
If I had understood, the table element "alarmwebprotokoll" defined into the
dbforms config file is the sql view, and the <*_sql> child elements
define the related operations on that view.
I think it's a good idea.
Anyway I have (up to now) a simpler case, and maybe too specific to the
application I'm developing.
I must swith a pointer from my view to the related "parent table". That pointer
is the event.tableId value ;^)
For example, when the EventEngine fires the NavNewEvent ("generated" by the
insert button related to my view), I can:
- obtain the table name from that event
- check if the event refers to my view;
- if yes:
- get the "parent table" id from the config object
(view = VIEW_ITEM, parent table = ITEM)
- set the event.tableId with the "parent table" id
(the old value was the VIEW_ITEM "table" id,
the new value is the ITEM table id)
Here's my dirty hack (just a test!):
class: org.dbforms.event.EventEngine
at line ~ 258:
if (action.startsWith("ac_new_")) {
logCat.info("---- about to instanciate NavNewEvent");
e = new NavNewEvent(action, request, config);
}
....
// fxt stuff....
logCat.info("------- :GPE generates the [" + e.getClass() + "] event");
logCat.info("------- :GPE table ID = [" + e.getTableId() + "]");
String myTableName = config.getTable(e.getTableId()).getName();
logCat.info("------- :GPE table name = [" + myTableName + "]");
if ((myTableName != null) && "VIEW_ITEM".equals(myTableName))
{
int myTableId = -1;
if ((myTableId = config.getTableByName("ITEM").getId()) != -1)
{
e.setTableId(myTableId);
logCat.info("------- :GPE - new table id = " + myTableId);
logCat.info("------- :GPE - new table name = " +
config.getTable(myTableId).getName());
}
}
// fxt stuff end
Here's the log infos:
INFO [Thread-1] (DbFormTag.java:1228) - end reached of VIEW_ITEM
INFO [Thread-1] (EventEngine.java:109) - ----- generatePrimaryEvent(): action
= [ac_new_3]
INFO [Thread-1] (EventEngine.java:176) - ---------------- *** action =
ac_new_3 ***
INFO [Thread-1] (EventEngine.java:259) - ---- about to instanciate NavNewEvent
INFO [Thread-1] (EventEngine.java:269) - ------- :GPE generates the [class
org.dbforms.event.NavNewEvent] event
INFO [Thread-1] (EventEngine.java:270) - ------- :GPE table ID = [3]
INFO [Thread-1] (EventEngine.java:273) - ------- :GPE table name = [VIEW_ITEM]
INFO [Thread-1] (EventEngine.java:281) - ------- :GPE - new table id = 2
INFO [Thread-1] (EventEngine.java:282) - ------- :GPE - new table name = ITEM
I'm testing that change... the insert operation works correctly (mmmhh...
strange!); the delete not yet...
Anyway I think that the best thing to do is to follow the generatePrimaryEvent()
method documentation ... using an event factory or adding the possibility to use
hook methods for the generated events...
/**
...
<p>this is alpha code. the goal for version 1.0 is to make
it more flexible and open it
for new code - it would be great to add new Web-Events without even compiling
this class.
</p>
<p>if you have a hint for me on this topics please mail me:
<[EMAIL PROTECTED]></p>
*/
public WebEvent generatePrimaryEvent() {
...
Well, I'm going to test a working solution and I will try to generalize my
problem... stay tuned ;^)
> Regards,
> Henner Kollmann
Regards,
Luca
-------------------------------------------------------
This sf.net email is sponsored by: viaVerio will pay you up to
$1,000 for every account that you consolidate with us.
http://ad.doubleclick.net/clk;4749864;7604308;v?http://www.viaverio.com/
consolidator/osdn.cfm
_______________________________________________
DbForms Mailing List
http://www.wap-force.net/dbforms