In February, I was blogging about - Workaround for LOV on Primary Key Attribute. Provided workaround and sample application was working nicely, but it was working only in edit mode, when already existing row was updated. There was a need in my project, to update previously developed workaround in order to have working functionality when current row is in create mode.
I'm posting updated sample application, you can download it - LOVPrimaryKeyCreate.zip. This sample implements workaround for LOV on Primary Key for both cases - edit and create modes. Most probably you will face described problem in current JDeveloper/ADF builds (5188 and 5205).
One specific with create mode is that Primary Key usually have database constraint - Mandatory:
This means, on runtime - when user will try to create new row and will do commit - validation error will be generated for LOV attribute. Its because value from dummy attribute will not be copied into real attribute, validation will fire first for empty real attribute value:
Its possible to solve this problem, by simply updating previously described workaround. Idea is to initialize real key attribute with some dummy value when create is invoked. In my sample, I'm using main key negative value retrieved from DBSequence. I'm assigning this value in overriden create method:
This means, validation will not be fired anymore and dummy value will be changed with a real one in doDML() method (same as in original version of workaround):
With described update, workaround works well for newly created row:
Este post es una actualización de un post anterior en el que Andrejus muestra como evitar un bug que se produce cuando queremos trabajar con una Lista de Valores (LOV) sobre un campo de una tabla. El post anterior solo consideraba el uso de LOV cuando la tabla estaba en modo de consulta, sin embargo esta actualización considera las tablas en modo creacion y lectura.