Sunday, 24 November 2013

Submitting the Page on Enter Key - OAF--passing param Hash Table

 

If you have a case where you want to submit the form when the user selects the Enter key.

So we will make the use of OABoundValueEnterOnKeyPress API & will associate ON_KEY_PRESS_ATTR attribute with the bean that needs to submit the page when ENTER key is pressed

import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;  
import java.util.Hashtable;  
import oracle.apps.fnd.framework.webui.OABoundValueEnterOnKeyPress;  
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;  
  
  
  
  
public void processRequest(OAPageContext pageContext, OAWebBean webBean)  
 {  
   super.processRequest(pageContext, webBean);  
  
    //Enter Button Handling  
//HelloName is the Id of the bean in which user will enter some value and press Enter Button  
OAMessageTextInputBean HelloName = (OAMessageTextInputBean)webBean.findChildRecursive("HelloName");  
  
if (HelloName != null)  
 {  
   Hashtable params = new Hashtable();    
   params.put ("Go", "Go");   
   HelloName.setAttributeValue(OAWebBeanConstants.ON_KEY_PRESS_ATTR,  
       new OABoundValueEnterOnKeyPress(pageContext,  
           "DefaultFormName",  //enclosing form name  
            params,   
            true,  //client validated  
            true)); // server validated  
           }                                        
  
  
  }  
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)  
{  
super.processFormRequest(pageContext, webBean);  
  
if (pageContext.getParameter("Go") != null)  
    {  
       //Once Enter Key is pressed you can handle it here.  
    }  

  }  

Creating MessageChoiceBean Programatically

 

Controller Code
     public void processRequest(OAPageContext pageContext, OAWebBean webBean)  
{  
super.processRequest(pageContext, webBean);  
String sMode = "test";  
OAApplicationModule am = pageContext.getApplicationModule(webBean);  
OAViewObject oaviewobject = (OAViewObject)am.findViewObject("xxScoResourceVO1");  
if(oaviewobject == null)  
{  
oaviewobject = (OAViewObject)am.createViewObject("xxScoResourceVO1","xx.oracle.apps.pa.poplist.server.testVO");  
}  
        
oaviewobject.setWhereClause("DESCRIPTION IS NULL OR DESCRIPTION = '" + sMode + "'"); //Setting where clause Dynamically of Poplist VO  
  
oaviewobject.executeQuery();  
OAMessageChoiceBean oamessagechoicebean = (OAMessageChoiceBean)createWebBean(pageContext, "MESSAGE_POPLIST");  
oamessagechoicebean.setPrompt("Back");  
oamessagechoicebean.setListViewObject(pageContext, oaviewobject);  
oamessagechoicebean.setListDisplayAttribute("Meaning");  
oamessagechoicebean.setListValueAttribute("LookupCode");  
    
oamessagechoicebean.setName("xxAddAsgmtApplyAction");  
oamessagechoicebean.setAllowBlankValue(false);  
oamessagechoicebean.setDefaultValue("RETURN_BACK"); //Setting Default Value  
webBean.addIndexedChild(oamessagechoicebean);  
}  
  
How to capture its Value  
  
String PoplistValue = oapagecontext.getParameter("xxAddAsgmtApplyAction");  

 

OAF – How to create a switcher region programmatically.


Create the switcher bean
OASwitcherBean status = (OASwitcherBean)createWebBean(pageContext,OAWebBeanConstants.SWITCHER_BEAN,null,null);
status.setViewUsageName(“myVO1″);
status.setViewAttributeName(“LovFlag”);
status.setDataType(“VARCHAR2″);
status.setLabel(“Status”);
//Create our first case, in this scenario it is a pick list
OAMessageChoiceBean approve = (OAMessageChoiceBean)createWebBean(pageContext,OAWebBeanConstants.MESSAGE_CHOICE_BEAN,null,”Case1″);
approve.setViewUsageName(“myVO1″);
approve.setViewAttributeName(“BonusStatus”);
approve.setDataType(“VARCHAR2″);
approve.setPickListViewUsageName(“PickListVO1″);
approve.setListDisplayAttribute(“Meaning”);
approve.setListValueAttribute(“Code”);
//Create our second case, here this is a pick list as above but with a different pick list vo source
OAMessageChoiceBean others = (OAMessageChoiceBean)createWebBean(pageContext,OAWebBeanConstants.MESSAGE_CHOICE_BEAN,null,”Case2″);
others.setViewUsageName(“myVO1″);
others.setViewAttributeName(“BonusStatus”);
others.setDataType(“VARCHAR2″);
others.setPickListViewUsageName(“PickList2VO1″);
others.setListDisplayAttribute(“Disp”);
others.setListValueAttribute(“Code”);
others.setDisabled(Boolean.TRUE);
//Add the two created cased to the switcher bean
status.setNamedChild(“Case1″,approve);
status.setNamedChild(“Case2″,others);
//Now add the switcher to what ever region you need to in your page, in the below case it is being added to a OATableBean
table.addIndexedChild(status);
Note: The above code assumes the cases of “Case1″ and “Case2″ are being returned as string values in the VO myVO1.LovFlag field which will drive the switcher case decision.


 

Deploying OAF Personalizations Using the Import/Export Command Line Tools

After personalizing and testing framework pages in a Development instance, you may wish to automate the transfer of these changes to another instance, rather than manually re-doing them all again. This objective can be achieved by exporting the personalizations from the Development instance, then importing them to a different instance or instances
You can either use the GUI interface in “Functional Administrator” (Personalization tab) to transfer personalizations, or can invoke the XMLImporter/XMLExporter commands directly from the command line. The Export tool allows you to export a package or xml file (along with translation information) from the MDS repository of a database instance to a .xml file (or .xlf file for translations). The command line Export tool is necessary if you wish to perform bulk translations of personalization documents.
This post provides the below detailed steps how to transfer personalizations from one instance to others using the XMLImporter/XMLExporter tool.

1. Get Document Name

Go to the page you want to copy the personalization from and click the “about this Page” link at the bottom of the page. You will see the page name with full path which starts with /oracle/apps/<prod>.
Ex: /oracle/apps/icx/por/wf/webui/ReqLinesNotificationsRN

2. Get the Personalization Document info

Run the following command in TOAD or other tools as APPS user   
?
1
2
set serveroutput on
exec jdr_utils.listCustomizations('<full document name from step 1>');
Example:
?
1
2
set serveroutput on
exec jdr_utils.listCustomizations('/oracle/apps/icx/por/wf/webui/ReqLinesNotificationsRN');
Output:
anonymous block completed
/oracle/apps/icx/por/wf/webui/customizations/site/0/ReqLinesNotificationsRN
Note: If there are multiple records returned by this command, you will need to use export/import each item individually that you wish to export. You may also find there are records returned for seeded personalizations provided by Oracle which do not need to be exported.

3. Use XMLExporter to export personalization document

?
1
2
3
4
java oracle.jrad.tools.xml.exporter.XMLExporter <personalization document from step #2>  \
-username "<username>" -password "<password>"  \
-dbconnection "(description=(address_list=(address=(protocol=tcp)(host=<host>)(port=<port)))(connect_data=(sid=<sid>)))" \
-rootdir "<output directory>"
Example:
?
1
2
3
java oracle.jrad.tools.xml.exporter.XMLExporter \
/oracle/apps/icx/por/wf/webui/customizations/site/0/ReqLinesNotificationsRN -username apps -password w3lcome123 \
-dbconnection "(description=(address_list=(address=(protocol=tcp)(host=myhost)(port=12345)))(connect_data=(sid=dev)))" -rootdir "$XXSCM_TOP/install" \
Here one file named ReqLinesNotificationsRN.xml will be created in the below path:
XXSCM_TOP/install/oracle/apps/icx/por/wf/webui/customizations/site/0. Open the file and you will able to view the personalizations that you have done.

4. Use XMLImporter to import personalization document

Run the below command in the Instance where you want to import your personalization.
?
1
2
3
4
5
java oracle.jrad.tools.xml.importer.XMLImporter \
<full path of the file you want to import> \
-username "<username>" -password "<password>"  \
-dbconnection "(description=(address_list=(address=(protocol=tcp)(host=<host>)(port=<port>)))(connect_data=(sid=<sid>)))" -rootdir "<top level directory>" \
-rootPackage "/oracle/apps/<prod>"
Example:
?

1
2
3
4
5
java oracle.jrad.tools.xml.importer.XMLImporter \
$XXSCM_TOP/install/ReqLinesNotificationsRN.xml \
-username apps -password w3lcome123 \
-dbconnection "(description=(address_list=(address=(protocol=tcp)(host= myhost)(port=12345)))(connect_data=(sid=dev)))" -rootdir "$XXSCM_TOP/install" \
-rootPackage "oracle/apps/icx/por/wf/server"


Dynamic Color change in OAF FrameWork

Import Classes:
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OADataBoundValueViewObject;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageStyledTextBean;
import oracle.apps.fnd.framework.webui.beans.table.OAAdvancedTableBean;
import oracle.apps.fnd.framework.webui.beans.table.OAColumnBean;
import oracle.apps.fnd.framework.webui.beans.table.OATableBean;



Put the below code under the "Process Request" block of the Controller. 


  super.processRequest(pageContext, webBean);
   OATableBean table = (OATableBean)webBean.
    findIndexedChildRecursive("ChecksVO");
    OAMessageStyledTextBean job = (OAMessageStyledTextBean)table.
    findIndexedChildRecursive("StatusLookupCode");
    OADataBoundValueViewObject cssjob = new OADataBoundValueViewObject(job,"Status");
    job.setAttributeValue(oracle.cabo.ui.UIConstants.STYLE_CLASS_ATTR, cssjob);

How to Clear Cache from Oracle Application without Bouncing Listener?

Caching Framework in oracle apps R12 comes with an administration User interface and it is available under the Functional Administrator responsibility. This interface can be used to perform administrative operations including changing the time-out values for cache components, looking at cache usage statistics, and clearing caches.
Here are the steps to clear all Global Cache:
1] Login to Functional Administrator responsibility – then choose Home.
2] Choose the ‘Core Services’ Tab – then the “Caching Framework” Sub-Menu.
3] Proceed to choose ‘Global Configuration’ from the left hand side menu.
4] In the far right choose ‘Clear all Cache’ button.
5] A screen prompts and confirms that the action will clear all cache on the middle tier server – choose Yes. Essentially, this just forces all user sessions to engage and validate – rather than using cached values.
6] A confirmation message is displayed, confirming that all cache has been cleared across middle tiers.
7] Proceed to test and confirm whatever change was made to the preference, profile, etc….
Please note that clearing the OA Framework cache can cause data issues if multiple users are engaged and transacting data in the application at the time cache is cleared. Please use this utility with proper care.

You can also clear cache for specific component. To do that you need to go to Core Services -> Caching Framework -> Tuning. Query the application (for example iProcurement) or by Name or code.  Select the component and clear the cache.
Import oaf pages from unix server or apps server

To import OAF pages within the server just use the steps:

Just go to $APPL_TOP and run the command below:

java oracle.jrad.tools.xml.importer.XMLImporter
$JAVA_TOP/xxcholas/oracle/apps/fnd/search/webui/EmpSearchPG.xml
-username APPS -password apps -dbconnection "(DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)
(HOST=<Host name of ip of the instance>)(PORT=<default port of the instance>)) (CONNECT_DATA= (SID=<SID of the instance>) ) )" -rootdir $JAVA_TOP ;


Calling Concurrent Program From OA Framework Pages


Calling a 
concurrent program from an OAF page is most frequently used functionality in oracle apps. It helps us to achieve the customized functionality in a page.


OA Framework provides the ConcurrentRequest class to call a concurrent program from the pages. The submitRequest() method of ConcurrentRequest is used for calling a concurrent program. The submitRequest() method takes 6 parameters and returns request id of the submitted concurrent request. Following is the syntax to use this method:


public int submitRequest( 

String ProgramApplication ,

String ProgramName ,
String ProgramDescription ,
String StartTime,
boolean SubRequest,
Vector Parameters ) throws RequestSubmissionException

Here are the descriptions of each of the components in the method:


ProgramApplication -Application Short name of application under which the program is registered.
ProgramName - Concurrent Program Name for which the request has to be submitted.
ProgramDescription - Concurrent Program Description.
StartTime - Time at which the request should start running.
SubRequest - Set to TRUE if the request is submitted from another running request and has to be treated as a sub request.

Parameters - Parameters of the concurrent Request.