Overblog
Suivre ce blog
Editer l'article Administration Créer mon blog
2 février 2006 4 02 /02 /février /2006 16:05

Purpose

This is a Javabean component that allow to enter a value from an input dialog box


imput dialog bean

The java code


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 ;

    }

}


Forms configuration

  • Copy the inputdialog.jar file in the /forms/java directory
  • Sign the inputdialog.jar file with your own certificate
  • Edit the /forms/server/formsweb.cfg file to add the jar file to the archive_jinit variable
archive_jini=f90all_jinit.jar,……,inputdialog.jar


Implementation Class property

    oracle.forms.fd.InputDialog
 



Properties that can be set

Set the title of the message box

 
Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETTITLE’, ‘the_title’ ) ; 


Set the text of the message box

Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETTEXT’, ‘the_text’ ) ;


Properties that can be read

The returned string

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



The sample dialog

  • 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

Partager cet article

Published by Oracle Forms community - dans Bean - JoptionPane
commenter cet article

commentaires