You are on page 1of 6

Big alert - Francois Degrelle

Oracle Forms Javabean


A java multi-choice alert box
Home page

1. Purpose
This is a Javabean component that allow to display an Alert box with many options

f.degrelle@free.fr - http://fdegrelle.over-blog.com/

Big alert - Francois Degrelle

f.degrelle@free.fr - http://fdegrelle.over-blog.com/

Big alert - Francois Degrelle

2. The Javabean
package oracle.forms.fd; import import import import import import import import java.util.StringTokenizer; oracle.forms.handler.IHandler; oracle.forms.properties.ID; oracle.forms.ui.VBean; javax.swing.JOptionPane; javax.swing.SwingUtilities; javax.swing.UIManager; javax.swing.plaf.metal.MetalLookAndFeel;

/** * A javabean multi choice alert for Oracle Forms * * @author Francois Degrelle * @version 1.0 */ public class BigAlert extends VBean { static static static static static static static private private private private private private String String String String String String int title = "" ; text = "" ; result = "" ; list = "" ; OptionList[] = new String[100]; sDelimiter = "|" ; icon = JOptionPane.QUESTION_MESSAGE ;

IHandler mHandler; static final ID pSetTitle static final ID pSetText static final ID pSetList static final ID pSetDelim static final ID pGetString

= = = = =

ID.registerProperty("SETTITLE"); ID.registerProperty("SETTEXT"); ID.registerProperty("SETLIST"); ID.registerProperty("SETDELIM"); ID.registerProperty("GETSTRING");

public BigAlert() { 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 == pSetList) { /** Set the list of choices **/ int i = 0 ; list = (String)value ; StringTokenizer st = new StringTokenizer(list,sDelimiter); while (st.hasMoreTokens()) { OptionList[i] = st.nextToken() ; i++ ; } return true; } else if (id == pSetText) { /** Set the message and display the dialog box **/ text = (String)value ; result = ShowAlert(); return true; } else if (id == pSetDelim) { /** Set the list delimiter **/ sDelimiter = (String)value ; f.degrelle@free.fr - http://fdegrelle.over-blog.com/

Big alert - Francois Degrelle 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 Alert box */ public static String ShowAlert() { String sReturn = (String)JOptionPane.showInputDialog( null, text, title, JOptionPane.QUESTION_MESSAGE, null, OptionList, OptionList[0]); if( sReturn == null ) return "" ; else return sReturn ; }

3. Forms configuration
Copy the bigalert.jar file in the /forms/java directory Edit the /forms/server/formsweb.cfg file to add the jar file to the archive_jini variable
archive_jini=f90all_jinit.jar,,bigalert.jar

4. How to implement this bean in your own form


Open your form Add a Javabean component to any block Set its Implementation class property to : oracle.forms.fd.BigAlert

5. The properties that can be sent to the bean

f.degrelle@free.fr - http://fdegrelle.over-blog.com/

Big alert - Francois Degrelle

The title of the alert box


Set_Custom_Property( BLOCK.BEAN_ITEM, SETTITLE, the_title ) ;

The choices list of the alert box


Set_Custom_Property( BLOCK.BEAN_ITEM, SETLIST, the_list ) ;

The values must be separated with the delimiter character ( Alt+124 by default)

The list delimiter


Set_Custom_Property( BLOCK.BEAN_ITEM, SETDELIM, char_delimiter ) ;

By default, the delimiter is | in the jar file

The text of the alert box


Set_Custom_Property( BLOCK.BEAN_ITEM, SETTEXT, the_text ) ;

6. The properties that can be read from the bean

The returned string


:BLK.ITEM := Get_Custom_Property( ' BLOCK.BEAN_ITEM', 1, 'GETSTRING' ) ;

7. The sample dialog


Download the bigalert.zip file Unzip the bigalert.zip file Copy the inputdialog.jar file in your /forms/java/ directory Edit your /forms/server/formsweb.cfg file Open the bigalert.fmb module (Oracle Forms 9.0.2) Compile all and run the module

This dialog allows to enter the title, the question and the option list of the alert box The code that shows the alert dialog box is located in the When-Button-Pressed trigger
-- Set the title -Set_Custom_Property( 'CTRL.DIALOG', 1, 'SETTITLE', :CTRL.TITLE ) ; -- Set the option list -Set_Custom_Property( 'CTRL.DIALOG', 1, 'SETLIST', :CTRL.LIST ) ; -- 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' ) ;
f.degrelle@free.fr - http://fdegrelle.over-blog.com/

Big alert - Francois Degrelle

f.degrelle@free.fr - http://fdegrelle.over-blog.com/

You might also like