Wednesday, July 11, 2012

Handling errors in tabular forms - don't forget the commit...

I always found manual tabular forms in APEX a sort of pain in the butt. I tried to avoid them whenever I could. But now and then there is no escape...
One reason why I dislike them is, when your submit process throws an error, your page is repainted again with all the fields in the original state. Sigh.. So you have to re-enter all your data and don't make that mistake again. 
The standard solution is to fill a collection with all your data on page load, build your tabular form on top of that collection, save the entered values into the collection and finally save the contents of your collection (or the entered values themselves, as they are equal on this point) to the real tables. So I implemented that.
But to my suprise, it didn't work! Debugging, looking at session state, etc nothing helped. Until I got the luminous idea of putting a "commit;" in the process that saves the entered values into the collection. That helped a lot...
I always thought that all processes committed automagically, but in fact it seems that all processes (probably the ones that fire on the same process point) are committed all together. Or rollbacked for that matter...
Maybe this will help you prevent in making the same mistake! 
Post a Comment