i created an insert page that basically displays all fields from one parent table, and two child tables.
i did this because my goal is to have one insert page for all 3 tables instead of three insert pages (one for each table).
i plan to implement my own custom postInsert() method in an interceptor for the parent table.
the following is my idea:
1) parent record created by DBForms
2) then i will manually insert the two child records within the postInsert() method of my interceptor.
what i am not sure of, is the best way to implement this postInsert() method.
should i make my own sql insert statements, create a PreparedStatement object, set the parameters, and call executeUpdate()?
or should i try to use the DBForms functions by creating my own DataSourceFactory, DbEventInterceptorData, and FieldValues objects and calling doInsert() for these two child tables?
any advice on this?
thanks in advance!
woodchuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(for those who don't know, this is necessary because DBForms will only collect the values for the fields that exist in the table that is declared in the <db:dbforms> tag. all other form field values have to be collected manually)
woodchuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What's about using autoUpdate=true for the subforms? In this case also the sbuforms should be inserted.
The only problem in this case is the missing parent id. if you generate this in an beforeINsert interceptor of the parent form and put it into the fieldvalues list the child form could use it from there.
Henner
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i would like to try your suggestion, but how can i use subforms for child tables for an insert page?
i tried 'wrapping' the html widgets from child tables within a subform but it would not generate the html because i believe it had no parent id.
the parent id is one of the textfields to be entered by the user, it's not generated by database.
this is like a catch-22 situation. the child fields need a parent id, but the parent id is not available since it will be entered by the user when inserting this new record.
is there a way to get around this?
what i ended up doing is basically just to generate all these child fields without any subforms at all. to DBForms, these fields do not belong to any table.. like independent fields. :p
tia,
woodchuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hihi,
i created an insert page that basically displays all fields from one parent table, and two child tables.
i did this because my goal is to have one insert page for all 3 tables instead of three insert pages (one for each table).
i plan to implement my own custom postInsert() method in an interceptor for the parent table.
the following is my idea:
1) parent record created by DBForms
2) then i will manually insert the two child records within the postInsert() method of my interceptor.
what i am not sure of, is the best way to implement this postInsert() method.
should i make my own sql insert statements, create a PreparedStatement object, set the parameters, and call executeUpdate()?
or should i try to use the DBForms functions by creating my own DataSourceFactory, DbEventInterceptorData, and FieldValues objects and calling doInsert() for these two child tables?
any advice on this?
thanks in advance!
woodchuck
btw, i already discovered that i have to collect the child table field values manually inside postInsert(), like so:
String childParam = ParseUtil.getParameter(data.getRequest(), "myChildField");
(for those who don't know, this is necessary because DBForms will only collect the values for the fields that exist in the table that is declared in the <db:dbforms> tag. all other form field values have to be collected manually)
woodchuck
What's about using autoUpdate=true for the subforms? In this case also the sbuforms should be inserted.
The only problem in this case is the missing parent id. if you generate this in an beforeINsert interceptor of the parent form and put it into the fieldvalues list the child form could use it from there.
Henner
hihi Henner,
i would like to try your suggestion, but how can i use subforms for child tables for an insert page?
i tried 'wrapping' the html widgets from child tables within a subform but it would not generate the html because i believe it had no parent id.
the parent id is one of the textfields to be entered by the user, it's not generated by database.
this is like a catch-22 situation. the child fields need a parent id, but the parent id is not available since it will be entered by the user when inserting this new record.
is there a way to get around this?
what i ended up doing is basically just to generate all these child fields without any subforms at all. to DBForms, these fields do not belong to any table.. like independent fields. :p
tia,
woodchuck