Wednesday, November 21, 2007

What the hell is JVM , Session , Cache ?

From quite some days, I find threads on OAF Forums, where people could not understand the basic terminology of J2EE like session,JVM , Oracle user session, cache etc. I think these terms are not new for people from Java background, but for people who come from pl/sql background or not from Java background, these terms might look like hammers.I remember one thread where I and Tapash were replying somebody asked whats' the difference between ICX session and http session, I wanted to reply, but I thought, replying there would make thread too long, i guess that thread already crossed 4 pages and replying there may not reach to all target audience.
So, I decided to write a small article for the same..... and in fact I must say my article is nothing but compilation of information from OAF Developer's guide , googling , metalink, blogs and lastly my knowledge....[You must be doubting on the last point.... even i am :)]

So, lets start with basic terminalogy:

About JVM
At the heart of the Java platform lies the Java Virtual Machine, or JVM. Most programming languages compile source code directly into machine code, suitable for execution on a particular microprocessor architecture. The difference with Java is that it uses bytecode - a special type of machine code.
Java bytecode executes on a special type of microprocessor. Strangely enough, there wasn't a hardware implementation of this microprocessor available when Java was first released. Instead, the processor architecture is emulated by what is known as a "virtual machine". This virtual machine is an emulation of a real Java processor - a machine within a machine (Figure One). The only difference is that the virtual machine isn't running on a CPU - it is being emulated on the CPU of the host machine.



The Java Virtual Machine is responsible for interpreting Java bytecode, and translating this into actions or operating system calls. For example, a request to establish a socket connection to a remote machine will involve an operating system call. Different operating systems handle sockets in different ways - but the programmer doesn't need to worry about such details. It is the responsibility of the JVM to handle these translations, so that the operating system and CPU architecture on which Java software is running is completely irrelevant to the developer.



The Java Virtual Machine forms part of a large system, the Java Runtime Environment (JRE). Each operating system and CPU architecture requires a different JRE. The JRE comprises a set of base classes, which are an implementation of the base Java API, as well as a JVM. The portability of Java comes from implementations on a variety of CPUs and architectures. Without an available JRE for a given environment, it is impossible to run Java software.
Differences between JVM implementations
Though implementations of Java Virtual Machines are designed to be compatible, no two JVMs are exactly alike. For example, garbage collection algorithms vary between one JVM and another, so it becomes impossible to know exactly when memory will be reclaimed. The thread scheduling algorithms are different between one JVM and another (based in part on the underlying operating system), so that it is impossible to accurately predict when one thread will be executed over another.
Initially, this is a cause for concern from programmers new to the Java language. However, it actually has very little practical bearing on Java development. Such predictions are often dangerous to make, as thread scheduling and memory usage will vary between different hardware environments anyway. The power of Java comes from not being specific about the operating system and CPU architecture - to do so reduces the portability of software.

Summary

The Java Virtual Machine provides a platform-independent way of executing code, by abstracting the differences between operating systems and CPU architectures. Java Runtime Environments are available for a wide variety of hardware and software combinations, making Java a very portable language. Programmers can concentrate on writing software, without having to be concerned with how or where it will run. The idea of virtual machines is nothing new, but Java is the most widely used virtual machine used today. Thanks to the JVM, the dream of Write Once-Run Anywhere (WORA) software has become a reality.

JVM Cache and Its impelemetation in Oracle Apps:

Qestions like what is cache? How is it related to JVM? How is caching implementated in Oracle Apps?Instead of me explaining this, it would be best if you go through the brilliant explanation by Mike Shaw on Steven Chan’s blog.Here is the link:
Mike Shaw's article about JVM Cache


HTTP SESSION

HttpSession is nothing but a java interface.The servlet container uses this interface to create a session between an HTTP client and an HTTP server.
The session persists for a specified time period, across more than one connection or page request from the user. A session usually corresponds to one user,
who may visit a site many times. The server can maintain a session in many ways such as using cookies or rewriting URLs.
This interface allows servlets to View and manipulate information about a session, such as the session identifier, creation time, and last accessed time
Bind objects to sessions, allowing user information to persist across multiple user connections.

ICX Session or Oracle Applications User Session
(Is it same as HTTP session/servelet session ?)


A http session or a servelet session usually corresponds to an application login/logout cycle, but that is not strictly true in the case of OA Framework applications.I tell u y ? When the user logs in to an OA Framework application, the OA Framework creates an AOL/J oracle.apps.fnd.common.WebAppsContext object and a browser session-based cookie that together keep track of key Oracle Applications context information like the current responsibility, organization id and various user attributes such as user name, user id,
employee id and so on.
The cookie contains an encrypted key identifier for a session row stored in the Applications database.Specifically, this is the servlet session ID which, in its decrypted form, serves as the primary key in the
ICX_SESSIONS table.(to get an idea do run Select * from ICX_SESSIONS , to get an exact idea of what information is stored in the table)
The WebAppsContext retrieves this key value after each request and uses it to query the current session state.
The Oracle Applications user session or ICX SESSION is associated and not dependent with a servlet session, because , it has its own life cycle and time-out characteristics. Generally, the Oracle Applications user session has a longer life span than the servlet session. The servlet session should time-out sooner.

User session is dependent on following profiles:

a)ICX: Limit Time :Determines the maximum Oracle Applications user session length( in
hours.

b)ICX:Session Timeout: Maximum idle time for the Oracle Applications user session
(specified in minutes).

While servelet session timeout is purely dependent on setting in Apache Jserv session timeout setting.

An Oracle Applications user session might be associated with multiple http servlet sessions. For example, the servlet session times out
while the user takes a phone call in the middle of creating an OA Framework expense report, then resumes work before the Oracle Applications user session
times out.If the Oracle Applications user session times out, aslong as the user does not close the browser window (so the browser session-based cookie isn't
lost) and no one deletes the corresponding session row in the ICX_SESSIONS table, the user can resume her transaction at the point where he stopped working
after being prompted to log back in.
Although the best practice as per Oracle standards is to sync ICX_SESSION and servelet session,till passivation feature is implenented in Oracle Apps. Passivation is still not supported in 11i and 12i.


This is straight from metalink “The ICX: Session Timeout option sets the the maximum number of minutes to wait before invalidating an idle ICX Session. The default value is null. The web server session timeout value, or more appropriately the Apache Jserv Session value is used to specify the number of milliseconds to wait before invalidating an unused session. The default value is 1800000 or 30 minutes.
We recommend that you set the ICX: Session Timeout and the Apache Jserv Session to be the same. It's better to be consistent and let the ICX session and the Apache Jserv (middle tier) session expire at the same time. If the ICX session expires before the Jserv session, the user will be presented with a login page even though the Jserv session is still active. If the user logs back in before the Jserv session expires, they will see the old state of their middle-tier transaction. This can be confusing, since from the point of view of the user there is no distinction between the ICX session and the Jserv session.
We also recommend that you do not set the Apache Jserv Session timeout to be any higher than 30 minutes. Longer idle sessions will drain the JVM resources and can also cause out of memory errors.
The session timeout for the webserver is specified via the following directive in the /Jserv/etc/zone.properties file.
session. timeout=1800000”


I think by now you must be crystal in ur understanding of basic key terms in J2EE.I would like to stress on one thing... JVM cache is shared across servelet/http sessions , and is purely dependent on first login, it can be removed progrmatically by invalidating the cache or by bouncing the apache server.

Any doubts or queries are welcome!

Friday, November 2, 2007

Setting the default selected date for an OAMessageDateFieldBean

I have seen couple of threads in recent past on OA Forums about setting default value in OAMessageDateFieldBean, so, did a little R n D :) on OAMessageDateFieldBean.

OAMessageDateFieldBean in framework, u will find its nothing but a onClick js event is called on the imageicon attached with messagetextinput bean(in case the type is Date) and OAInlineDatePickerBean is opened in a modal js window.

Setting deafult date in the OAMessageDateFieldBean, also sets the OAInlineDatePickerBean , as it takes the default value from OAMessageDateFieldBean.
So, here is code for setting/getting value both in both in OAMessageDateFieldBean and OAInlineDatePickerBean :
import java.sql.Date;
import java.text.SimpleDateFormat;
java.sql.Timestamp;

//defining format of date
SimpleDateFormat f = new SimpleDateFormat("mm/dd/yyyy");
//define date as string
String dateString = "06/30/1984";
//defining new java.sql.date
Date sqlDate=new Date(f.parse(dateString).getTime());


OAMessageDateFieldBean dateField = (OAMessageDateFieldBean)webBean.findIndexedChildRecursive();
dateField.setValue(pageContext,sqlDate);


//getting oracle.jbo.domain.Date object from OAMessageDateFieldBean
//in process form request
Timestamp ts = (Timestamp)dateField.getValue(pageContext);
System.out.println(ts.getTime());
java.sql.Date select = new java.sql.Date(ts.getTime());
oracle.jbo.domain.Date sd=new oracle.jbo.domain.Date(select);

//You can also set min Value and Max value in OAMessageDateFieldBean which
//will also be set in OAInlineDatePickerBean
//Here is code
dateField.setMinValue(minDate);
dateField.setMaxValue(maxValue);


I hope this helps all.

Tuesday, September 25, 2007

Implementing a simple watch in a OA Framework Page

I hope this is interesting ... implementing a watch in OA Framework page.There can be several other functionalities, one can do after implementing this watch.Here i am just writing a simple function for javascript watch,you can take an idea.... and change this function accordingly.

Just read this function.....

/* Here is the javascript function, which is self explainatory
Read this function carefully
to understand it.*/

function update()
{
//Define a new date object
var today=new Date();

var hours=today.getHours();
var minutes=today.getMinutes();
var seconds=today.getSeconds();

//for formatting output
if (hours<10)
hours="0"+hours;
if (minutes<10)
minutes="0"+minutes;
if (seconds<10)
seconds="0"+seconds;

//writing output to message text input
document.getElementByID('OAclockDisplay').value=hours+":"+minutes+":"+seconds;

//refreshing ever sec
setTimeout("update()",1000);
}

I hope this clear. Now here are the steps how you can put it in your OA Framework page.Add a message text input to your page, say its id is "OAclockDisplay".

Now add this code in process request of controller of page:

//storing javascript function is a string
// "\" is used as escape character
String s="function update(){var today=new Date();var hours=today.getHours();var minutes=today.getMinutes();var seconds=today.getSeconds();if(hours<10){hours=\"0\"+hours;} if(minutes<10){minutes=\"0\"+minutes;} if(seconds<10){seconds=\"0\"+seconds;} document.getElementById('OAclockDisplay').value=hours+\":\"+minutes+\":\"+seconds;setTimeout(\"update()\",1000);}";

//getting body bean
OABodyBean bodyBean = (OABodyBean)pageContext.getRootWebBean();

//attaching javascript function to page
pageContext.putJavaScriptFunction("update",s);

// calling this function on load of body bean
String javaS = "javascript:update();";
bodyBean.setOnLoad(javaS);

We are done, run this page you will be able to see a watch in oa framework page in that particular message text input.
Cheers!

Friday, September 14, 2007

Few Useful threads

Here is the list of few useful of the many threads replied by me on OA forums:

1)Dynamic tool tip in classic table
http://forums.oracle.com/forums/thread.jspa?messageID=2056047&#2056047

2)Putting a different color message in OA Framework page for instrtuction text etc:
http://forums.oracle.com/forums/thread.jspa?messageID=1966417&#1966417

3)How to make the cursor as "Busy" (i.e. HOURGLASS) and not like the usual "ARROW"..., when ur doing lot of tasks on an event
http://forums.oracle.com/forums/thread.jspa?messageID=1940174&#1940174

4)Delete Personilization:
http://forums.oracle.com/forums/thread.jspa?messageID=1959670&#1959670

5)Putting error message stack on OA page:
http://forums.oracle.com/forums/thread.jspa?messageID=1890435&#1890435

6)Make some rows' some columns read only in a table:
http://forums.oracle.com/forums/thread.jspa?messageID=1813973&#1813973

7)Not able to find server.xml
http://forums.oracle.com/forums/thread.jspa?messageID=1787572&#1787572

8)Runtime VO
http://forums.oracle.com/forums/thread.jspa?messageID=1886728&#1886728

9)Using alerts in OA Framework Page
http://forums.oracle.com/forums/thread.jspa?messageID=2067435&#2067435

10)Showing pl/sql exceptions in java(Also, see this thread if ur facing previous message stack retaining probling while using OAExceptionUtils class)
http://forums.oracle.com/forums/thread.jspa?threadID=598831&start=0&tstart=0

11)Dynamic CSS class generation in a OAF Page
http://forums.oracle.com/forums/thread.jspa?threadID=598398&tstart=15

http://forums.oracle.com/forums/thread.jspa?threadID=605557&start=15&tstart=0

12)

Thursday, September 6, 2007

Dependent Dynamic message choicelists

This is one of the most common scenario in any web application page.Basically here i am just giving an idea how to code for dependent message choicelists in OA Framework page both at page level or in a collective ui feature like table or hgrid.

3 Message Choicelists in a Page :

Lets consider the first scenario, where we have 3 dependent message choicelists(mc1,mc2,mc3), these can be n in number, just follow the same approach.Here mc1,mc2 and mc3 are the item ids of the message choice lists in the page UIX file, which are attached to vo instances mc1VO1 and mc2VO1 and mc3vo1 respectively.Assuming "Intial value" property value is blank and "Add blank value" is "true" in property inspector for all three poplists.
Lets start from controller code, please read comments, as they explain each and every line..

Controller Code

/*Code in Controller*/
import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;

//Code in process request
OAMessageChoiceBean mc1 = (OAMessageChoiceBean)webBean.findChildRecursive("mc1");
/*The poplist data object that OA Framework creates the first
* time is cached in the JVM and reused
*until you explicitly disable caching
*Hence, use setPickListCacheEnabled API to stop JVM
* from caching Poplist values, this API needs to be called on any Poplist
* where the VO where clause keeps on changing
*/
mc1.setPickListCacheEnabled(false);
//Similarly for second Poplist
OAMessageChoiceBean mc2 = (OAMessageChoiceBean)webBean.findChildRecursive("mc1");
mc2.setPickListCacheEnabled(false);

//Similarly for third Poplist
OAMessageChoiceBean mc3 = (OAMessageChoiceBean)webBean.findChildRecursive("mc3");
mc3.setPickListCacheEnabled(false);

//Code in process form request
/*If a value is selected in mc1
*"update" is the name of PPR event
* attached to poplist mc1
*/
if("update".equals(pageContext.getParamete(OAWebBeanConstants.EVENT_PARAM))) {
String value_selected=pageContext.getParameter("mc1");
//Priniting the value selected
System.out.println("value_selected in mc1>>"+value_selected);
//if the selected value is not null
if(!(("".equals(value_selected)) (value_selected==null)))
{
//then calling the method in AM which will reinitialise VO query
// in second message choicelist and not third because
//the value selected in seocond will null
//as we have turned Add blank value to true
//and initial value is null in property inspector
Serializable[] param = {value_selected};
am.invokeMethod("initmc2VOQuery", param);
// if user selects some value in first choicelist
// pass some dummy_value in mc3vo query so that it returns 0 records
//or you can put some condition in vo query like where 5=6
Serializable[] param = {dummy_value};
am.invokeMethod("initmc3VOQuery", param);
}
else
{
// if user selects null in first choicelist
// pass some dummy_value in mc2vo query so that it returns 0 records
//or you can put some condition in vo query like where 5=6
//doing this for mc2vo1 and mc3vo1
Serializable[] param = {dummy_value};
am.invokeMethod("initmc2VOQuery", param);
am.invokeMethod("initmc3VOQuery", param);
}
}

/*If a value is selected in mc2
*"update1" is the name of PPR event
* attached to poplist mc2
*/
if("update1".equals(pageContext.getParamet(OAWebBeanConstants.EVENT_PARAM)))
{
String value_selected=pageContext.getParameter("mc2");
//Priniting the value selected
System.out.println("value_selected in mc2>>"+value_selected);
//if the selected value is not null
if(!(("".equals(value_selected)) (value_selected==null)))
{
//then calling the method in AM which will reinitialise VO query
// in third message choicelist
Serializable[] param = {value_selected};
am.invokeMethod("initmc3VOQuery", param);
}
else
{
// if user selects null in second choicelist
// pass some dummy_value in mc3vo query so that it returns 0 records
//or you can put some condition in vo query like where 5=6
//doing this only for mc3vo1
Serializable[] param = {dummy_value};
am.invokeMethod("initmc3VOQuery", param);
}
}

Dependent message choicelists in Table

Controller Code :

/*Cosider two message choicelist items HeaderPoplistItem and LinePoplistItem in table with item id "XXX".We will use setListVOBoundContainerColumn api,which is typically used for containers that repeat it's content multiple times and want to attach different set of records for each iteration, eg table or hgrid.*/

OATableBean XXX = (OATableBean)webBean.findChildRecursive("XXX");

/*LinePoplistItem is a poplist item, in which view def is filled and not view instance this is based on initial value in HeaderPoplistItem which is a poplistwith view instance name*/
OAMessageChoiceBean LinePoplistItem = (OAMessageChoiceBean)XXX.findChildRecursive("LinePoplistItem");
//
LinePoplistItem.setListVOBoundContainerColumn(0, XXX,"HeaderPoplistItem");


AM code
//Also note for runtime dependency of table of hgrid poplists, you have attach PPR in the LinePoplistItem and in your event method in AM write:
getVO().setWhereClauseParam(0,);
getVO().executeQuery();

In this article , i have covered the Dependent Dynamic message choicelists in tables and independent poplists on page. Hope this scenario is now clear.


Friday, August 31, 2007

More updates on Javascript usage

Common errors in Pop up pages and their resolution:
One thing i missed out in previous post is the profile options related to pop up page .Sometimes while trying to run a pop up page you get errors like:
"You are trying to access a page which is no longer active....."

The root cause of this error are the profile options:
1) FND_VALIDATION_LEVEL - None
2) FND_FUNCTION_VALIDATION_LEVEL - None
3)Framework Validation Level- None
They should be none in order to avoid the error.The root cause of the error is MAC key url validation, which is governed by the above 3 profiles.

Also, if you are getting error in doing a page submit on pop up page confirm:
FND: Framework Compatibility Mode profile option should have value greater than or equal to "11.5.10".

Will be back with a artcle on databound values in the next post.

Monday, July 2, 2007

JavaScript In OA Framework

“To be or not to be…… is the question…..!” The famous soliloquy by William Shakespeare in Hamlet…. a similar scenario we have in OA Framework for JavaScript!
The exact lines of Developers’ guide for use JavaScript are as follows:
“UIX and the OA Framework are rapidly adding new features to provide a more interactive user experience
(partial page rendering, automatic table totaling, and so on). You are certainly encouraged to leverage these
features as they are released, however, you should not attempt to implement them yourself before they're
ready.
In short, JavaScript is prohibited without explicit permission from the OA Framework team. Furthermore, you
must have confirmation from the corporate UI design team that a Javascript implementation is essential for
your product.”


But this is really funny, if you are developing some web pages for your application, so expect all web features in the framework, and if they are missing definitely you have to use JavaScript to implement them, you cannot wait , for the framework team to implement them.

So, if you are developing some custom pages for your application, you can go ahead with JavaScript. I will advice to refrain from JavaScript if your extending standard OA pages, because, Oracle may not support it, in that case.
In case of custom pages, anyways oracle will not support customization, so you dam care for support.

Another interesting thing in OA Framework is that you will methods for JavaScript usage method in almost every UIX beans; in fact, framework team must be using them in development of various features in OA Framework.

What is JavaScript?

JavaScript is the Netscape-developed object scripting language used in millions of web pages and server applications worldwide. Netscape's JavaScript is a superset of the ECMA-262 Edition 3 (ECMAScript) standard scripting language, with only mild differences from the published standard.

Contrary to popular misconception, JavaScript is not "Interpretive Java". In a nutshell, JavaScript is a dynamic scripting language supporting prototype based object construction.

For those who are interested and new to concept of javascript, should explore this link
http://www.javascriptmall.com/learn/

I will like to stress on one point before starting the various scenarios where JavaScript can be used, is that JavaScript is a browser specific script and may behave different in different browsers, so you must test your application code on various browsers like internet explorer, mozilla firefox, Netscape etc.

Scenarios in OA Framework, where you are bound to use javascript.
Various Pop Up Window scenarios
Closing a Window
Timely refresh of a OA Page
Client side events on different beans


Various Pop Up Window scenarios:
This is the most common scenario in OA Framework, as framework does not provide anything for pop windows, except standard LOVs, which may or may not suit your requirement.I think I have replied this thread several times on OA Framework forum, in fact, thought of writing this article, after I replied the thread so many times J.
Lets, take the most common scenario:
You need to fire a custom page as a pop up window , do some processing(say add some new values in one of the VO) and on returning back to base page, reflect the changes on base page(say the base page VO should reflect the changes done on pop up page).
Follow these steps for the solution:
1. To open a custom page..... as a modal window.... u can have a link or button(button of type button and not submit button) on base page with destination url property as following javascript:

javascript:var a = window.open('OA.jsp?page=/XXX/oracle/apps/xxx/......&retainAM=Y', 'a','height=500,width=900,status=yes,toolbar=no,menubar=no,location=no'); a.focus();

Meaning of each parameter in this javascript:
· RetainAM:If this is equal to “Y”, AM will be retained when child window is opened.
· Height: Height of the pop up or child window.
· Width: Width of pop up or child window
· Status: String, Specifies a priority or transient message in the window's status bar (This property is not readable.).
· Toolbar: Object, Represents the browser window's tool bar.
· Menubar: Object, Represents the browser window's
menu bar.
· Location:Location of window on the sceen
· Resizable: if resizable=yes, is included in above api, then child window size can be maximized.By default the child window size is fixed user cannot, increase or decrease the size.
· Scrollbar: if scrollbar=yes, is included in above api, scrollbars will appear in the child window.

Please Note : While trying to run a pop up page you get errors like:
"You are trying to access a page which is no longer active....."

The root cause of this error are the profile options:
1) FND_VALIDATION_LEVEL - None
2) FND_FUNCTION_VALIDATION_LEVEL - None
3)Framework Validation Level- None
They should be none in order to avoid the error.The root cause of the error is MAC key url validation, which is governed by the above 3 profiles.There can be scenarios when your DBA/Admin would not allow you to set these profiles at site level in order to maintain security of Apps from cross site scripting attacks.


In such scenarios, or I will say in all scenarios, its better to use a utility class in OAF called OABoundValueEmbedURL which secures your js function by bypassing the MAC key validation.You can use following code to attach js url programatically to a button/image bean :
OAImageBean img = (OAImageBean) webBean.findChildRecursive("");
//url of the page
String url ="/XXX/oracle/apps/xxx/......"
//retain am parameter
string amMode ="true";
//additional parameters i want to pass to to pop up page
String params="order_id={@workorder_id}";

//Computing page_url
String page =
url + "&retainAM=" + amMode + "&fndOAJSPinEmbeddedMode=y" + "&" +
params;
//Computing final url
String destURL =
OAWebBeanConstants.APPS_HTML_DIRECTORY + OAWebBeanConstants.APPLICATION_JSP +
"?" + OAWebBeanConstants.JRAD_PAGE_URL_CONSTANT + "=" + page;

//Securing js function from MAC key validation
OABoundValueEmbedURL jsBound =
new OABoundValueEmbedURL(img, "openWindow(self, '", destURL,
"' , 'longTipWin', {width:" + width +
", height:" + height +
"}, true); return false;");

//Attaching bound value embed url to on click of image.
img.setAttributeValue(OAWebBeanConstants.ON_CLICK_ATTR, jsBound);

There are 3 important points to understand here :
1) This code has to be written in process request and not process form request, because as per OA Developer standards bean properties can only be set in process request and not process form request.

2)The additional parameters you want to pass can be passed at runtime, this is especially in case of tables/hgrids where lets say a particular column has link and each row has different parameter values to pass, you can send VO attributes as parameters like @Vo_attr_name.This will make your pop window link to be dynamic as each row js url will have different parameter values depending upron row of VO.

3)If you see the final url computed here I have used an additional parameter like
fndOAJSPinEmbeddedMode=y, this is especially in case of pages which use jtfchrome.jsp where in the JTF/JTT and OAF flows are integrated.This parameter will take care that the JS URL OF LOV page, should not be changed to jtfcrmchrome.jsp from OA.jsp which results in error of lov page.


In one of the 2 approaches you would be able to open the pop up page.

2. Now, you can do your pop up page processing by the pop page controller.
3. Now your child window should have two buttons, one for select(submit button) and another for close(button).On press of select button you will have all vaues in your trasient VO, and you can also show user a message like, " values created successfully....".The second button will be of type "button", whose destination url property will be

javascript:opener.submitForm('DefaultFormName',0,{XXX:' abc'});window.close();
(In this api you can pass n number of attributes, the second parameter will be correspondingly n-1, e.g you have to pass three attr, then second parameter of api will be 2
javascript:opener.submitForm('DefaultFormName',2,{'XXX':' abc','XXX1':'efg','XXX2':'ijk'});window.close(); )
Now in the process request of the base page CO, u can get parametre 'XXX' from the pagecontext....so
if((("abc").equals(pageContext.getParameter("XXX"))))
{///LOGIC to initialize or not to intialize some components of base page}

Please Note :
1)From Apps R12.1, the framework is also validating parameter security, so getting js parameter values by pageContext.getParameter("XXX"), can throw security exception error
FND_FORM_POST_SECURITY_FAILED. To bypass this parameter security validation , you need to take js parameter values directly from http request using following code:
pageContext.getRenderingContext().getServletRequest().getParameter("XXX");

2)Also, if you are getting error in doing a page submit on pop up page confirm:
FND: Framework Compatibility Mode profile option should have value greater than or equal to "11.5.10".


Closing a Window
To open a custom page..... as a modal window.... u can have a link or button(button of type button and not submit button) on base page with destination url property as following javascript:window.close();

Timely refresh of a OA Page
Lets, consider a scenario when you want a page refresh after every 10 seconds.Here is javascript for it:javascript:setTimeout(window.location.reload(),10000);where 10,000-->10 sec(10,000 milli sec)

What you need to do is attach with onLoad method of OABody bean, so that when the page is rendered, this javascript is triggered.You can code like this:

OABodyBean bodyBean = (OABodyBean) oapagecontext.getRootWebBean();

String javaS = “javascript:setTimeout('window.location.reload()',10000)”;
bodyBean.setOnLoad(javaS);

Client side events on different beans:
Above I have given a few of million possible situations of javascript in OA Framework.In almost all ui beans u will find methods like setOnLoad *, setOnClick* etc., where you can attach a javascript function to the bean.
Will be back with more examples of javascript in OA Framework, soon!