Sunday 23 August 2015

OAF: OAMessageChoice / poplist / dropdown not refreshing the data

Sometimes when we use the MessageChoice /poplist / dropdown in our page and we want to see different data everytime the page loads. The example screnarios are 
  • Data has to be different based on the user logged in.
  • Data has to be different based on the responsibility used to access the page. 
  • Dropdown has to list the newly added data from the previous session or by a different user just before this page is accessed.
The poplist data object that OA Framework creates the first time, is cached in the JVM and reused until you explicitly disable caching. The caching is enabled by default. So, if you are looking for a fix for data not refreshing in your dropdown/poplist, you need to disable the poplist caching explicitly using the below API in processRequest() method of your controller.

poplistBean.setPickListCacheEnabled(false);

Example usage :
 import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;  
 OAMessageChoiceBean poplistBean = (OAMessageChoiceBean)webBean.findChildRecursive("<MessageChoice_Field_Name>");  
 poplistBean.setPickListCacheEnabled(false);  

From the Dev Guide :

You should explicitly disable poplist caching in the following cases:
  1. When you use the view object row getter method to encrypt the value for a poplist.
The poplist data object that OA Framework creates the first time is cached in the JVM and reused until you explicitly disable caching. When you encrypt the value of a poplist in the view object row getter method, the encrypt method uses the current Oracle E-Business Suite user session ID as a key to encrypt the poplist value. When you decrypt the values in their controller to further process the poplist, the decrypt method will also use the current Oracle E-Business Suite user session ID as the key to decrypt the value.
Since the poplist data object is cached at a JVM level, the data object will always contain the cached value with the encryption done with the first Oracle E-Business Suite user session ID and will reuse that value to render the poplist. Since the decrypt method also uses the current Oracle E-Business Suite user session ID as the key and the encrypted value that is returned is a cached value, the decrypt method will fail and return a null value. To avoid this scenario, you should always disable poplist caching when you encrypt the poplist values in their view object row getters.
2. When the poplist data (the query string or WHERE clause parameters of the poplist view object) keeps changing with user or thread-specific context.
Only data that can be shared across user threads within the JVM should be stored in the cache. Otherwise, the cache size increases redundantly, thereby increasing memory consumption.


Feel free to point out if anything is missing/wrong in this blog.