About Me

My photo
Dhaka, Dhaka, Bangladesh
✔4x Salesforce Certified ✔Web Application Developer ✔Database Developer with DWH/ETL/BI • Successful solution engineer and developer with 16+ years of experience multiple technology and in different countries. Proficient in implementing business requirements into the technical solution. Experience handling all phases of the project lifecycle from discovery through to deployment. Worked as technical lead for a team of junior developers to make sure code stayed in line with requirements and standard best practices. Skilled at integrating disparate systems with Salesforce.Experience implementing Salesforce Community Cloud at two previous companies.

Thursday, April 21, 2011

How do you open a Popup from Oracle Forms

Using   web.javascript_eval_expr Statement

Example
                  web.javascript_eval_expr('window.showModelessDialog("help/SomeFile.html", "''", "dialogLeft:120px; dialogTop:260px; dialogWidth:800px; dialogHeight:455px; scroll-y:on; resizable:yes; status:no; help:no;");');
                  web.javascript_eval_expr('window.showModalDialog("help/SomeFile.html", "''", "dialogLeft:120px; dialogTop:260px; dialogWidth:800px; dialogHeight:455px; scroll-y:on; resizable:yes; status:no; help:no;");');             
                  web.javascript_eval_expr('window.open("help/SomeFile.html", "WinHelp", "location=no,menubar=no,left=220,top=260,width=800,height=455,toolbar=no,resizable=yes,scrollbars=yes");');

Integrating Oracle Forms 11g with JavaScript

Integrating Oracle Forms 11g with JavaScript


<Do not delete this text because it is a placeholder for the generated list of "main" topics when run in a browser>

Purpose

In this tutorial you set up and run an application that demonstrates Oracle Forms and JavaScript integration. The application uses Cascading Style Sheets (CSS) and a popular third party JavaScript library called jQuery.

Time to Complete

Approximately 30 minutes

Overview

The demonstration application integrates simple forms with a dHTML menu system that controls both the form and other dHTML objects appearing in the same browser window, such as a date picker and an image viewer. With this application you can demonstrate how Oracle Forms can call out to these browser widgets and call into the Oracle Forms Runtime via the Forms client applet.
The resulting application, with the menu and the date picker visible, looks like this:

Prerequisites

Before starting this tutorial, you should:
1. Have access to or have installed Oracle Forms version 11.1.1. You may use either Release 1 (R1) or Patch Set 1 (PS1), although the directory structures of these releases are somewhat different.

2. Have access to an Oracle database with the scott schema ( EMP and DEPT ) installed.
Warning: For security reasons, it may not be advisable to install the sample schemas into a production database. If you do install them, you should use passwords other than default passwords, although default passwords are used in the examples shown in tutorials provided by Oracle. When you are finished using the sample schemas for tutorial and demo purposes, you may drop them by issuing the following SQL*Plus command for each installed sample schema:
DROP USER CASCADE;
If you are using the sample schemas for the first time, you may find that you must unlock the schema user, and then grant CONNECT and RESOURCE roles to it. You can do this by using Oracle Enterprise Manager, which is part of Oracle.
Alternatively, you can issue the following SQL*Plus commands:
ALTER USER scott IDENTIFIED BY tiger ACCOUNT UNLOCK;
GRANT CONNECT, RESOURCE to scott;



3. Use Internet Explorer 7 or later. Version 6 of IE and any version of Firefox does not allow the application's JavaScript menu (a Milonic menu) to show in front of the Forms applet. However, the Milonic menu can be used with frames; see Resources.

Definitions

This demonstration uses a few Web standards that may be unfamiliar to Forms developers, such as:
  • dHTML: This acronym stands for dynamic HTML, an umbrella term for using client side languages like JavaScript, or server side languages like PHP and Java Server Pages, to create dynamic (as opposed to static) Web pages.

  • JavaScript: JavaScript has emerged as the dominant client side scripting language. Like PL/SQL, it is pointerless, but while PL/SQL is compiled to byte code, JavaScript is interpreted. It is imperative, weakly typed, and object oriented (but prototype based rather than class based), and its functions are first-class entities.

  • CSS: CSS stands for Cascading Style Sheets, which you can use to define the style of a Web site. You use it in the demonstration application to make the applet appear to be a part of the larger browser page.

  • DOM: An understanding of the DOM, or Document Object Model, is crucial in order to be effective when programming in JavaScript. The DOM is the model by which HTML objects are represented and manipulated.
See Resources for more information on these topics.

Setting Up the Application

Use following steps to setup the application:
1. From the expanded zip file, copy the .fmb files ( found in the JSInteg\Solutions\jsdemo folder) to a directory of your choice.


2 . Open the modules in Forms Builder, connect as scott, and compile the forms to the same directory as the .fmb files.


3. Copy the js.html file to the Forms configuration directory. The path for this directory is defferent depending on the release of JDeveloper that you are using:
  • For Release 1 (R1):
    \user_projects\domains\\servers\ WLS_FORMS\stage\formsapp\11.1.1\formsapp\config
  • For Patch Set 1 (PS1):
    \config\FormsComponent\forms\server\
  •  

 
4. Copy these directories: img, JSCal2, lightbox05, menu , and transEffects

and these files: jquery.js, jsdemo.css, jsdemo.html, and jsdemo.js

to the following directory:
  • For Release 1 (R1):
    \user_projects\domains\\servers\
    WLS_FORMS\stage\formsapp\11.1.1\formsapp\formsweb.war\


  • For Patch Set 1 (PS1):
    \user_projects\domains\\servers\
    WLS_FORMS\tmp\_WL_user\formsapp_11.1.1\e18uoi\war\

     

5. Edit jsdemo.html and modify the hostname and port values according to your installation. These values are located toward the end of the file.

6. Create a new configuration section called [javascript] in the formsweb.cfg file. In 11g, you could do this by using Enterprise Manager, but you can also edit the file manually. For the sake of simplicity, this tutorial shows manually editing the file.
Add some parameters to the configuration section. The defaults for height and width are a little too big for the application. The new color scheme called swan looks good for this application, so set colorscheme and lookAndFeel to accomplish that. Make sure that JavaScript support is turned on, and also name the applet.
Use the following settings:
[javascript]
width=440
height=300
splashScreen=no
background=no
colorScheme=swan
lookAndFeel=oracle
logo=no
applet_name=forms_applet
enableJavascriptEvent=true
baseHTMLjpi=js.html


7 . Edit the default.env file: Add the directory where you saved the forms to the environment variable FORMS_PATH.
For example, append to FORMS_PATH:
    ;D:\Data\MyForms\JSIntegDemo


Running the Application

To demonstrate the features of the application, perform the following steps:
1. Run the application by issuing the following URL in your browser, substituting the value for :
http://:9001/forms/jsdemo.html You do not need to invoke the servlet URL (frmservlet) because the iframe in the application calls the Forms servlet.

 
2. Use the self-explanatory JavaScript menu to navigate to submenus and perform different operations.
For example, invoke the Query menu, enter an employee name, such as WARD, in the search box, and click Go.

The form displays the record for the specified employee.


3. To redisplay all the records, select Query > Execute from the menu.

Navigate to the hiredate field in Employees form. Use the up- and down- arrow keys to scroll between records, noticing the corresponding change in the date picker calendar.

4. Select a date from the calendar, which updates the hiredate of the employee record.

5 . Select View > Departments to navigate to the Department form.

6 . Scroll up and down to navigate between different departments, noticing the changes in various images.

Summary

In this tutorial, you learned to set up and run the sample application that demonstrates JavaScript integration in Oracle Forms 11g.
The application hides the Forms standard menu and replaces its functionality with a JavaScript-based menu system. This menu is connected to the Forms applet. The application implements Javascript-based UI widgets as extensions to the Forms widget set, seamlessly making use of these widgets.

Resources

Forms 11g new features: Javascript-API / WHEN-CUSTOM-JAVASCRIPT-EVENT

Forms 11g allows the direct communication between the generic java-applet in the browser and the world around. The new JavaScript-API implements this functionality.

In Forms 11g we have a new trigger, system-variables and built-ins for the communication with the JavaScript-API.

The trigger WHEN-CUSTOM-JAVASCRIPT-EVENT fires each time, when JavaScript raises an event to forms. In the trigger we can use the payload which is stored in two system-variables. system.javascript_event_name and :system.javascript_event_value.


Informations, which were transfered from HTML to Forms, can be easily used:


In this little example we transfer in the payload the event-name "NewForm" and in the event-value the name of a form. The data is transfered from the internet-page in this way::
< INPUT id="outside_field_id">
< SCRIPT>
  function set_field (field_id, myValue) {
    document.getElementById(field_id).value=myValue;
  };
  function clickEvent1()
  {
    document.forms_applet.raiseEvent("NewForm", "payload");
  }
< /SCRIPT>
< INPUT id="button1" type="button" onClick="void clickEvent1();" value="NewForm">

Internally the method raiseEvent of the class forms_applet is used. The applet's name has to be assigned in the formsweb.cfg to the parameter applet_name.
applet_name=forms_applet

Forms can communicate bi-directional with the HTML. Therefore we can use the new built-ins web.javascript_eval_expr and web.javascript_eval_function.
web.javascript_eval_expr
    ('document.getElementById("outside_field_id").value="' ||
     :control.ti_inside || '";');
  web.javascript_eval_expr 
    ('set_field("outside_field_id", "' || :control.ti_inside
     || '")');
  :control.ti_get_value := web.javascript_eval_function
    ('document.etElementById("outside_field_id").value');

This example-code fills in the HTML-page a field named "outside_field_id" through the built-in web.javascript_eval_expr. Two techniques can be used. Direct Assignment or the call of a javascript-function, e.g. „set_field“.
You can read field through web.javascript_eval_function. The returnvalue is the value of the corresponding field in the HTML, in this case "outside_field_id".

This is another example of how important the new features in Forms 11g are. Now it's possible for forms to communicate with the world outside the browser's applet!