Professional Documents
Culture Documents
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/
f.degrelle@free.fr - http://fdegrelle.over-blog.com/
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
= = = = =
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
f.degrelle@free.fr - http://fdegrelle.over-blog.com/
The values must be separated with the delimiter character ( Alt+124 by default)
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/
f.degrelle@free.fr - http://fdegrelle.over-blog.com/