Oracle Forms – Javabean
This is a Javabean component that allow to enter a value from an input dialog box
package oracle.forms.fd;
import oracle.forms.handler.IHandler;
import oracle.forms.properties.ID;
import oracle.forms.ui.VBean;
import javax.swing.JOptionPane;
/**
*
A javabean input dialog box for Oracle Forms
*
* @author Francois
Degrelle
* @version 1.0
*/
public class InputDialog extends VBean {
static
String title = "" ;
static
String text = "" ;
static
String result = "" ;
static
int icon = JOptionPane.QUESTION_MESSAGE ;
private
IHandler mHandler;
private
static final ID pSetTitle =
ID.registerProperty("SETTITLE");
private
static final ID pSetText =
ID.registerProperty("SETTEXT");
private
static final ID pGetString =
ID.registerProperty("GETSTRING");
public
InputDialog() {
super();
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public void
init(IHandler handler) {
super.init(handler);
mHandler = handler;
}
/**
* Set the properties from Forms
**/
public
boolean setProperty(ID id, Object value) {
if (id
== pSetTitle) { /** Set the title **/
title = (String)value ;
return true;
}
else if
(id == pSetText) { /** Set the message and display
the dialog box **/
text = (String)value ;
result = ShowDialog();
return true;
}
else {
return true;
}
}
/**
* Get the result string from Forms
**/
public Object
getProperty(ID pId)
{
if (pId ==
pGetString)
{
return
"" + result ;
}
else
{
return
super.getProperty(pId);
}
} // getProperty()
/**
* Display the dialog box
*/
public
static String ShowDialog() {
String
sReturn = "" ;
sReturn
= JOptionPane.showInputDialog(null,
text, title, icon);
if(
sReturn == null ) return "" ;
else
return sReturn ;
}
}
Ř Copy the inputdialog.jar
file in the /forms/java directory
Ř Edit the /forms/server/formsweb.cfg
file to add the jar file to the archive_jinit variable
archive_jini=f90all_jinit.jar,……,inputdialog.jar
Ř Open your form
Ř Add a Javabean
component to any block
Ř Set its Implementation
class property to : oracle.forms.fd.InputDialog
Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETTITLE’, ‘the_title’ ) ;
Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETTEXT’, ‘the_text’ ) ;
:BLK.ITEM := Get_Custom_Property( ' BLOCK.BEAN_ITEM', 1, 'GETSTRING' ) ;
Ř Download
the inputdialog.zip file
Ř Unzip the inputdialog.zip
file
Ř Copy the
inputdialog.jar file in your /forms/java/ directory
Ř Edit your /forms/server/formsweb.cfg
file
Ř Open the inputdialog.fmb
module (Oracle Forms 9.0.2)
Ř Compile all and
run the module
This dialog allows to enter the
title and the question of the dialog box
The code that shows the input
dialog box is located in the When-Button-Pressed trigger
-- Set the title --
Set_Custom_Property( 'CTRL.DIALOG', 1, 'SETTITLE',
:CTRL.TITLE ) ;
-- Set the text and show the input dialog
box --
Set_Custom_Property( 'CTRL.DIALOG', 1, 'SETTEXT', :CTRL.QUESTION ) ;
-- Get the input string --
:CTRL.TEXT := Get_Custom_Property( 'CTRL.DIALOG', 1,
'GETSTRING' ) ;