i like the 'list_and_single' type forms and i basically use these all the time. i have taken these templates and modified them to be 'all-in-one' functional forms (list/search, update, delete, insert).
the problem is if there is an insert error, the page will be redrawn with the error message(s), but without any records at all. that is, the user may be paginating through the table records and on the fifth pagination page decide to insert a new record. however if the insert does not pass validation then the user loses their current 'position'; the page is becomes empty basically and there are no navigation buttons at all (first/previous, next/last).
i found out it is because of the following DbFormTag code:
because navEvent is set to null and the footer flag is set to true, this causes no table data to be displayed.
on my forms, i don't use any subforms at all, so i have no child fields. all fields are from one parent table.
i want to be able to re-load/re-display all the current table data (like PageReloadEvent does), even when there are insert errors. but i'm not sure what other 'flags' or conditions i can modify in the code to do this, and without breaking the current behaviour...
any advice?
thanks in advance!
woodchuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i added a new DbFormTag attribute. i think this was the easiest (if not only) way to handle this situation. and in the code i mentioned i modified to check against this flag. i've tested it here and it works fine. the default value for this attribute is "false" and this does not change the current behavior.
when "true" it will basically proceed with the next condition statements. and because of this, the posted page is reloaded even during insert errors (for insert and view combo pages).
do you want me to post the changes? 2 files are affected:
- DbFormTag
- dbforms.tld
thanks,
woodchuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes, i have the redisplayFieldsOnError attribute on my pages set to "true" already. however, somehow it seems to only work for the <db:body> section only (ie. when updating records).
my insert new record section is within the <db:footer> area but the redisplayFieldsOnError attribute doesn't seem to apply (even though this area is still within <db:dbform>).
woodchuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hihi Henner,
i like the 'list_and_single' type forms and i basically use these all the time. i have taken these templates and modified them to be 'all-in-one' functional forms (list/search, update, delete, insert).
the problem is if there is an insert error, the page will be redrawn with the error message(s), but without any records at all. that is, the user may be paginating through the table records and on the fifth pagination page decide to insert a new record. however if the insert does not pass validation then the user loses their current 'position'; the page is becomes empty basically and there are no navigation buttons at all (first/previous, next/last).
i found out it is because of the following DbFormTag code:
if ((webEvent != null)
&& EventType.EVENT_DATABASE_INSERT.equals(
webEvent.getType()) && (errors != null)
&& (errors.size() > 0)
&& (webEvent.getTable().getId() == getTable().getId())) {
// error in insert event, nothing to do!
navEvent = null;
resultSetVector = null;
setFooterReached(true);
}
because navEvent is set to null and the footer flag is set to true, this causes no table data to be displayed.
on my forms, i don't use any subforms at all, so i have no child fields. all fields are from one parent table.
i want to be able to re-load/re-display all the current table data (like PageReloadEvent does), even when there are insert errors. but i'm not sure what other 'flags' or conditions i can modify in the code to do this, and without breaking the current behaviour...
any advice?
thanks in advance!
woodchuck
hihi Henner,
i added a new DbFormTag attribute. i think this was the easiest (if not only) way to handle this situation. and in the code i mentioned i modified to check against this flag. i've tested it here and it works fine. the default value for this attribute is "false" and this does not change the current behavior.
when "true" it will basically proceed with the next condition statements. and because of this, the posted page is reloaded even during insert errors (for insert and view combo pages).
do you want me to post the changes? 2 files are affected:
- DbFormTag
- dbforms.tld
thanks,
woodchuck
Yes of course! Here is my private e-mail address:
Henner.Kollmann@gmx.de
Thanks,
Henner
ok i have e-mailed the 2 files for you.
*warning*: i couldn't verify that i am working with the latest dbforms.tld file because i couldn't find it in cvs (where is this placed?).
however, my changes to DbFormTag.java were done with the latest version in cvs.
thanks!
woodchuck
dbforms.tld is not edit directly - it generated from /etc/taglib_docu.xml during the build process.
Have you tried the redisplayFieldsOnError attribute of dbforms? Seems that this attribute has nearly the same function.
Henner
hihi Henner,
ah, i see. that is nice!
yes, i have the redisplayFieldsOnError attribute on my pages set to "true" already. however, somehow it seems to only work for the <db:body> section only (ie. when updating records).
my insert new record section is within the <db:footer> area but the redisplayFieldsOnError attribute doesn't seem to apply (even though this area is still within <db:dbform>).
woodchuck
actually, i think why redisplayFieldsOnError does not work is because DbFormTag has specific logic that treats INSERT operations differently.
because of this part of the code:
if ((webEvent != null)
&& EventType.EVENT_DATABASE_INSERT.equals(webEvent
.getType()) && (errors != null)
&& (errors.size() > 0)
&& (webEvent.getTable().getId() == getTable().getId())
&& !hasLoadOnInsertErrorsSet()) {
// error in insert event, nothing to do!
navEvent = null;
resultSetVector = null;
setFooterReached(true);
}
which is exactly where i made the modification to check the extra new flag "loadOnInsertErrors".
woodchuck
Then we should use the redisplayFieldsOnError attribute at this place too instead of introducing a new one!
What do you think - will it work for you?
Henner
hihi Henner,
yes, that is even better! i didn't think of that..
i'll make the change and send you the file again.
thanks!
woodchuck