原文地址:JavaScript In OA Framework (需FQ)

“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!


Hi Mukul,

I have a base page, there is a text input and image like LOV.
I open a popup window after I click on the image.then do some search.then I want to close the popup window and change the text input value on base page.but I want to it behaves like LOV ,It do not refresh the whole base page,but change the text input value only.
Is it possible?

I make a button with "javascript:opener.submitForm('DefaultFormName',1,{'pop':'abc'});window.close();" on the popup window. but I when I click the button,it will refresh the whole base page.by the way,I can't get the event in proecess request but I get the event in process Form request. so I put the the follow codes in the process form request.
if((("abc").equals(pageContext.getParameter("XXX"))))
{
pageContext.setForwardURL(//base page)
}


Binghao,
It is possible to pass value from pop up page to base page without refresh of base page, just like standard LOV.
If 
pop up page textinput Id=> popuptextinput
base page text input ID=>basepageMessageTextInput

You need to attach this javascript in pop up page button:
javascript:window.opener.document.getElementById('basepageMessageTextInput').value= document.getElementById('popuptextinput').value;window.close()

--Mukul


Hi Mukul,

I have the following scenario where I need to close a OA framework page based on the parameter passed to that page.

So to do that I am getting parameter from the page Context. In your blog you have referred to destination in the base page..In my scenario, I am forwarding to a OA framework page from an applet. So is it possible to put the same java script

javascript:window.close();

in the controller file and close the window based on the parameter? If so can you give some pointers?

I ve already tried the following in vain

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

String javaS = "javascript:window.close()";
bodyBean.setOnNavigate(javaS);

Thanks
VPD


Hi Mukul,
I have a requirement in OAF page like this.
There is a MessageStyledText with a Fire Action set to it. This is displayed as a Link Item in the page. I right click on the Link Item and pop up is shown. I click on the 'Open in New Window' event in the Popup. The result page has to open in a new Window.
I tried this is not working.
I tried with StaticStyledText its working fine. But not with Message StyledText. Please let me know, if I can capture the 'Open in New Window' event of the Popup Window.

Thanks in Advance
Murali


VPD,
In ur case , if i got u correctly flow is coming from a form and to OA Framework page, where based on a parameter passed from form u need to close the oaf page... rite.... in that case although u can use window.close(), but since this is the main window, u would get a pop up to confirm that u wanna close the window, is it acceptable? If yes, then u can use it.
--Mukul


Giridhar ,
As per ur requirement, y r u not using oalink bean?Y u wanna use text beans? I think link bean will best suit ur requirement.
--Mukul


hi mukul,
iam having one sanerio,
if the user logon by giving his username and password.how to check whether his user name and password is valid or not.after checking the user name and password the enduser clicks on function say example myinformation,then it has to display his Information like his name,address,mobile number just like a read only page.can you give any suggession for this.

regards
Ramkumar


Ramkumar,
Validation of FND username/password can be dome via APIs in webapps context like

WebAppsContext ctx = new WebAppsContext
("T:\\users\\dbc_files\\secure\\ap618dbs_dev115.dbc");
// Process the error stack to make sure that the WebAppsContext object
// was created correctly.
OAException oaex = OAExceptionUtils.processAOLJErrorStack(ctx.getErrorStack());
if (oaex != null)
{
throw oaException;
}
// You can now initialize the user session for the new WebAppsContext
// either by validating the session if you have an Oracle Applications
// user session id, or by logging in with a user name and password
// as shown.
ctx.getSessionManager().validateLogin("fwktester", "fwkdev");

--Mukul


Hi Mukul,
I have a page, on this page let's say if the user is ideal for 5 minutes then I have to give a warning like you are ideal from last 5 minutes. But if the user is ideal for last 10 minutes then I have to perform some other action. Is it possible to do this?

I wrote the following code for the first Action..
String s="function update(){alert('You are ideal from last 5 min ');}";
pageContext.putJavaScriptFunction("update",s);

String javaS = "javascript:setTimeout(\"update();\", "+ 5*1000*60+" );";

OABodyBean bodyBean = (OABodyBean) pageContext.getRootWebBean();
bodyBean.setOnLoad(javaS);

Can you please guide me how to handle the second action or call one more java script function once more.


Hi,
This requirement is possible to implement. I have discussed this in OA Framework Forums. See this thread link:

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

--Mukul


Hi Mukul,

Creating New Region in Exsiting Page is "Customization by extension" or Modification by extention".

Does Personalization support Creating New region.

I have created two custom table and i want to show that field in exsting screen.

Please suggest.

Thanks

Rajeev Dave


Hi Mukul,

Creating New Region in Exsiting Page is "Customization by extension" or Modification by extention".

Does Personalization support Creating New region.

I have created two custom table and i want to show that field in exsting screen.

Please suggest.

Thanks

Rajeev Dave


Hi Mukul,

I have a requirement where in when I click a Submit Button on the UI, a JavaScript Confirmation Message needs to be showed. Only if the user clicks OK on the confirmation, the logic in ProcessFormRequest API of controller needs to get executed.
We do not want to use the OADialog object here due to our custom requirements.
Could you pls let me know how this can be done ?


Hi Mukul,

I have a requirement where in when I click a Submit Button on the UI, a JavaScript Confirmation Message needs to be showed (something like 'Are you sure to proceed with this operation ? '). Only if the user clicks OK on the confirmation, the logic in ProcessFormRequest API of controller needs to get executed.
We do not want to use the OADialog object here due to our custom requirements.
Could you pls let me know how this can be done ?


Rajesh,
I have replied a thread similar to your requirement in OA Framework Forum. Here is ths link:
Confirm Thread in OAF forum


Rajesh,
Due to formatting problems, I am not able to give exact link in last post, basically the url for the thread is

http://forums.oracle.com/forums/thread.jspa?messageID=2055132�

In this url
Remove the "?" at last and attach
"&" concatenated with "#2055132", then this thread will open up.


Hi Mukul,

A quick question on java script to open a other page.

How to open the other page as a model window. I mean how to make parent as not navigable until we close the child window (same as lov). I tried in different java script methods, but no luck with those.

Is this child page should also exist in same AM? I have 2 complete diffent pages, in one scenario I want to open that page do updates and come back to main page.

Can you help me on this..

Thanks in Advance

Regards,
Anji


Anji,

How to open the other page as a model window. I mean how to make parent as not navigable until we close the child window (same as lov). I tried in different java script methods, but no luck with those.

>>>>>> You can use OABoundValueEmbedURL api to attach OAF js api used in LOV to open modal pop up window, here is the sample code:

String page ="/XXX/oracle/apps/xxx/aaa/bbb/webui/TestPG";
String destURL = APPS_HTML_DIRECTORY + OAWebBeanConstants.APPLICATION_JSP + "?"+ OAWebBeanConstants.JRAD_PAGE_URL_CONSTANT+ "=" + page1+"&retainAM=Y";

OABoundValueEmbedURL jsBound = new OABoundValueEmbedURL(btn2,"openWindow(self, '", destURL, "' , 'longTipWin', {width:"+900+", height:"+400+"}, true); return false;");

//button to which u need to attach 
//this js function
//this should be a button
//and not submit button
OAButtonBean b = (OAButtonBean)webBean.findChildRecursive("(id of button)");
b.setAttributeValue(oracle.cabo.ui.UIConstants.ON_CLICK_ATTR, jsBound);

Is this child page should also exist in same AM? I have 2 complete diffent pages, in one scenario I want to open that page do updates and come back to main page.
>>>You should keep the same AM ideally it will help you retain VO values.
--Mukul


Thx Mukul,

It's working. Where can I get documents realted to these. I have much more customizations to do on this task.

I need to pass parameters and disabling standard links in child PG like logout,home etc(for this I am trying to create Region and calling it instead of page).

Can you share some links or preferable docs related to these?

Thanks a lot man..

Regards,
Anji


Anji,
Since js is not supported in OAF, there is no documentation on Javascript usage in OAF.(There might be an internal documenetation available inside Oracle for the same.)

This is more how u can implement ur js knowledge in OAF. You can see /OA_HTML/cabo/oajsLibs/
which contain all js libs implemented in OA Framework or write ur own js functions.

How to pass parameters between pop up and base page... just search Oracle OAF forum... u will find numerous threads replied by me in various scenarios.Also have discussed that in article as well as see first question in this article for the same.

--Mukul


Hi Mukul,

I have a base page with some 10 text input values.
There is a button "PButton".Now once I click the button following steps should happen:
1)All the input values will go to backend call pl/sql procedure and web services will return validated values.
2)The results will display on pop up page.

Now the problem is "PButton" should be a button or 'submit' button as with normal button pop up page is opening but form is not submitted and with submit button form getting submitted but pop up window not opening.

Also I have to show the results in a table how to create dynamic table?


Pc,
Y don't you use process request of pop up page for this? Get all the textinput values from the VO(I am assuming pop up and base page AM is same) in process request of pop up page.... then pass these values in webservice proxy class call, whatever validated values u get... u can show on your pop up page.
--Mukul


JavaScript In OA Framework的更多相关文章

  1. OA Framework - How to Find the Correct Version of JDeveloper to Use with E-Business Suite 11i or Release 12.x (Doc ID 416708.1)

    APPLIES TO: Oracle Applications Framework - Version 11.5.10.0 to 12.2.2 [Release 11.5.10 to 12.2] In ...

  2. How To Get Log, Trace Files In OA Framework Pages And Concurrent Request Programs

    Goal   Solution   References APPLIES TO: Oracle Supplier Lifecycle Management - Version 12.1.2 and l ...

  3. Oracle OAF 应用构建基础之实现控制器 (转)

    原文地址: Oracle OAF 应用构建基础之实现控制器 设计一个OA Controller 如OA Framework Page解析中所描述的,OA Controller定义了web beans的 ...

  4. Javascript MV framework 对比

    Javascript 最近的framework笔记多,大致可分以下3类.单向绑定简单直接.ajax从service拿数据传递给viewtemplate进行绑定.当然这个过程也可以在服务器端来做,.ne ...

  5. JavaScript资源大全中文版(Awesome最新版)

    Awesome系列的JavaScript资源整理.awesome-javascript是sorrycc发起维护的 JS 资源列表,内容包括:包管理器.加载器.测试框架.运行器.QA.MVC框架和库.模 ...

  6. 【原创】(AMD)JavaScript模块化开发(dojo)

    AMD原理等在这里就不进行说明了,作者也是菜鸟一枚,只是对自己的一个实例进行说明,如有错误,望指出. 首先,先推荐一篇AMD方面的文章,有兴趣的可以参考:http://efe.baidu.com/bl ...

  7. JavaScript测试工具比较: QUnit, Jasmine, and Mocha

    1. QUnit A JavaScript Unit Testing framework. QUnit is a powerful, easy-to-use JavaScript unit testi ...

  8. 优秀的JavaScript开发框架

    JavaScript基本上是一个面向对象的脚本语言,创建web应用程序和互动网站.Javascript框架也被称为Javascript库.JavaScript框架很容易提高设计web开发工作,提供了许 ...

  9. 最近面试的题目(WEB、Service、SQL、JavaScript)

    整理一下最近面试被问到的主要题目.由于本人主要是做WEB及WEB SERVICE这块,使用的语言主要是C#,数据库主要用到的也是MSSQL.所以就分成这些块来整理(有些是在面试之后才意识到回答不对), ...

随机推荐

  1. 更换 nodejs npm 镜像为 淘宝 镜像

    淘宝npm镜像官方介绍文档:https://npm.taobao.org/ ,使用命令在这个官方文档里查询. 安装工具cnpm: $ npm install -g cnpm --registry=ht ...

  2. 基于Android应用《玩转英语》(总报告)

                                                                         基于Android应用<玩转英语>   摘  要 ...

  3. flash,sram

    flash写入的内容不会因电源关闭而失去,读取速度慢,成本较低,一般用作程序存储器或者低速数据读取的情况. sram有最快的读写速度,但电源掉落后其内容也会失去,价格昂贵,一般用作cpu的二级缓存,内 ...

  4. 详解C中的volatile关键字【转】

    本文转载自:http://www.cnblogs.com/yc_sunniwell/archive/2010/06/24/1764231.html volatile提醒编译器它后面所定义的变量随时都有 ...

  5. linux中线程池【转】

    本文转载自:http://blog.csdn.net/yusiguyuan/article/details/18401277 一.线程池 大多数的网络服务器,包括Web服务器都具有一个特点,就是单位时 ...

  6. SPOJ LAS(BFS)题解

    题目:VJ 思路: BFS+回溯,但是要剪枝,看了dalao的题解,超时+WA无数发,终于过了 #include<cstdio> #include<cstring> #incl ...

  7. 51nod 1003 阶乘后面0的数量

    每一个 2 与一个 5 相乘,结果就增加一个零. 所以求 n! 后面的连续零的个数,其实就是求其中相乘的数含有因子每对因子 2 与 5  的个数. 又因为从1到某个数,所含 2 的个数比 5 多,所以 ...

  8. 断开网络连接的dos命令

    https://zhidao.baidu.com/question/154994771.html 或者采用服务关闭开启模式,不过没有上面的好用net stop "network connec ...

  9. LA 4329 乒乓比赛

    https://vjudge.net/problem/UVALive-4329 题意: 一条大街上住着n个兵乓球爱好者,经常组织比赛切磋技术.每个人都有一个不同的技能值ai.每场比赛需要3个人:两名选 ...

  10. UVa 1602 网格动物(回溯)

    https://vjudge.net/problem/UVA-1602 题意:计算n连通块不同形态的个数. 思路: 实在是不知道该怎么做好,感觉判重实在是太麻烦了. 判重就是判断所有格子位置是否都相同 ...