Overblog
Suivre ce blog
Editer l'article Administration Créer mon blog
3 février 2006 5 03 /02 /février /2006 17:30

Purpose

This bean allows to display buttons with a html content.
The content can be text or image.


On the screenshot below, we can see a button with an image that comes from an internet url
(<img src="http://....">)


HtmlButton

The java code


package oracle.forms.fd;

import java.awt.*;
import java.awt.event.*;

import java.util.StringTokenizer;
import javax.swing.JButton;
import oracle.forms.ui.CustomEvent;
import oracle.forms.ui.VBean;
import oracle.forms.ui.VButton;
import oracle.ewt.button.PushButton;
import oracle.forms.handler.IHandler;
import oracle.forms.properties.ID;
import oracle.forms.properties.Property;

/**
 * A javabean to display buttons with HTML content
 *
 * @author Francois Degrelle
 * @version 1.0
 */

public class HtmlButton  extends VBean implements ActionListener
{
  public final static ID SetLabel      = ID.registerProperty("SETLABEL"); 
  public final static ID SetBG         = ID.registerProperty("SETBACKGROUND");   
  public final static ID WBP           = ID.registerProperty("BUTTONPRESSED");   
  private IHandler  m_handler; 
  protected JButton b1  ;
 
  public HtmlButton()
  {
     super();
     b1 = new JButton(""); 
     b1.setActionCommand("push");
     b1.addActionListener(this);
     add(b1) ;

  }
     
  public void actionPerformed(ActionEvent e) {
        CustomEvent ce = new CustomEvent(m_handler, WBP);
        dispatchCustomEvent(ce);
    }
   
  public void init(IHandler handler)
  {
    m_handler = handler;
    super.init(handler);
  }     
 
 
  public boolean setProperty(ID property, Object value)
  {
    if (property == SetLabel)
    {
      String label = value.toString().trim();
      b1.setLabel(label);
      return true;
    }
    else if (property == SetBG)
    {
      String color = value.toString().trim();
      int r=-1, g=-1, b=-1, c=0 ;
      StringTokenizer st = new StringTokenizer(color,",");
      while (st.hasMoreTokens()) {
               c = new Integer((String)st.nextToken()).intValue()  ;
               if( (c <0) || (c > 255) ) c = 0 ;
               if( r == -1 ) r = c ;
               else if( g == -1 ) g = c ;
               else if( b == -1 ) b = c ;
             }
      b1.setBackground( new Color(r, g, b)) ;
      return true;
    }
    else
    {
     return super.setProperty(property, value);
    }
  }
 
}


Forms configuration

  • Copy the htmlbutton.jar file in the /forms/java directory
  • Sign the htmlbutton.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,……,htmlbutton.jar


Implementation Class property

    oracle.forms.fd.HtmlButton
 



Properties that can be set

The background color of the button

Set_Custom_Property( 'BLOC3.BEAN_ITEM',1, 'SETBACKGROUND','rgb_color' ) ;


The label


Set_Custom_Property( ‘BLOCK.BEAN_ITEM’, ‘SETLABEL’, ‘the_label’ ) ;



The sample dialog

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

      

The code that set the button properies is located in the When-New-Form-Instance trigger

 -------------------
  --  Text button  --
  -------------------
 -- Set the background color --
  Set_Custom_Property( 'BLOC3.BEAN',1, 'SETBACKGROUND','143,161,253' ) ;
 
  -- Set the label --
  LC$ButLabel := '<html><center>'
  || '<font size=5 color=#ff0000>Co<font size=5 color=#00ff00>lo<font size=5 color=#0000ff>red</u></b></font>'
  || '<br><font size=3 color=#ffff00><b>HTML B</b><i>utton</i></font>'  ;
 
  Set_Custom_Property( 'BLOC3.BEAN',1, 'SETLABEL', LC$ButLabel ) ;
 
  --------------------
  --  Image button  --
  --------------------
 -- Set the background color --
  Set_Custom_Property( 'BLOC3.BEAN2',1, 'SETBACKGROUND','255,255,255' ) ;
  LC$ButLabel := '<html><table border="1"><tr><td align="center" valign="center"><img src="
http://fdtool.free.fr/forms-pjc-bean/tmp/will.jpg" height="80" width="80" align="middle"></td></tr></table>' ;
  Set_Custom_Property( 'BLOC3.BEAN2',1, 'SETLABEL', LC$ButLabel ) ;





Partager cet article

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

commentaires

Igor 21/10/2009 17:23



HELP PLEASE


Firstly, Thanks for the HTMLButton PJC. I was looking
for a way to make animated gif function inside my forms.



1.   I have downloaded the zip file, exported it and copied htmlbutton.jar file in the /forms/java
directory


2.   I also signed jar file
this way:


D:DevSuiteHome_1formsjava>jarsigner -keystore myKeystore
test.jar myself


Enter Passphrase for keystore: igorcb


jarsigner: unable to open jar file: test.jar


3.   Finally I have edited /forms/server/formsweb.cfg file and added the jar file
to the archive_jinit variable


Sadly after all that when I open the demo form in
forms an error is displayed when I try to edit layout FRM-13008 saying that oracle.forms.fd.HtmlButton JavaBean
was not found. When I run the form buttons are shown with the customized colors but they do not show the
HTML


What do I have to do to make the HtmlButton
work?


 


Thanks on advance


Igor mailto:igorcb@cre.com.bo



Oracle Forms community 21/10/2009 18:30


At runtime, display the Java Console to see what error is raised. Maybe the JAR file is not loaded.