Thursday, December 5, 2013

Access key with Lov Popup dialog - issue and solution

This post is related to issues with actions components with Access Key and popup dialog models.

 The issue is when the popup model is launched say lov, same time if you have any Submit action with  Access Key enabled , you can execute that action using the access key. That is, you can submit the action even when the popup model is opened.

Use case :  Entering the invalid value in lov field, it will show invalid value entered as error  message on tabout or on submit. its a normal flow.
                 In case if you submit the page with access key when the popup is lauched, it wont show  the error  message, instead it submits the invalid value to model and exception thrown.

  1. Consider Dept Lov is attached to Employee view  DepartmentId Attr.
  2. Test in a test page, Drag drop the Employee vo in the page and put create button and commit   button.
  3. Add Access key to the Commit button say letter "C", for keyboard access ALT + SHIFT+C(in mozilla) commit action will execute
  4. Run the page and Enter invalid value say "1" (there no department id in departments table)., and LOV popup launches,




  5. Then now use the Access key ALT+SHIFT+C, popup disappears and Integrity constraint error comes.



This is a bug ,and already its submitted to oracle Bug Id #10170506
 Access key should be disabled when model popup is active..

Solutions:
 
  To avoid this kind of exception, you can show the proper message by handling them like below

 1. Validate in the model, add the key exist or list query validation and show the proper message.
    for key exists validation, I shown below


  Add the validation for the Key exists validation for Lov Field DepartmentId,
  


Now test the screen and submit the action with Access Key when the popup(lov) is active. it will show the proper message, In this use case check below message,




 2. Other way you can validate and show the message from the backing bean.

 3. You can disable the button on launch of popup, and enable it on close of popup
     Note: You can do this by javascript and server listener.. will post that in my another post soon.

 Sample source is here download for the above use case.(uses Oracle XE - HR schema)