Hyperlink JavaBean Information

The Hyperlink Javabean  provides a widget that looks and acts just like a normal HTML hyperlink.  This includes support for displaying a separate color once it has been visited and when the mouse is over it.  The Bean can be used to submit a normal URL to the Browser, or it can be used to execute a normal piece of PL/SQL code..  The JavaBean is integrated into Forms using the Forms FBean package which registers and integrates with the JavaBean at runtime.

Modules In This Demo

The Hyperlink demo consists of the following files (relative directories shown in brackets):

  1. hyperlink.fmb/fmx [forms]- The demo form
  2. Hyperlink.java [src/oracle/forms/demos/beans] - source code for the JavaBean class
  3. hyperlink.jar [classes]- the compiled and jarred java class.

The doc directory and the classes directory contain the JavaDoc for the code and the compiled classes respectively

Reusing the code

Setting up Forms Services

In order for an application to be able to use the Hyperlink JavaBean  the relevant configuration in the formsweb.cfg file has to ensure that the supplied hyperlink.jar (or another jar file containing the compiled Hyperlink.class) is included in the relevant archive setting.

An entry in the formsweb.cfg file for an application that used the Hyperlink JavaBean  would look like this:

[Hyperlink]
pageTitle=OracleAS Forms Services - Hyperlink Demo
IE=jinitiator
baseHTMLJInitiator=demobasejini.html
archive_jini=frmall_jinit.jar,hyperlink.jar
form=hyperlinkforms/java
width=675
height=480
separateFrame=false
splashScreen=no
lookAndFeel=oracle
colorScheme=blue
background=/formsdemo/images/blue.gif

Using the Bean in your Form

To use the Hyperlink JavaBean you must first create a normal Forms Bean area.  You do not need to set the implementation class for this field as this will all be handled at runtime by the FBean integration. 

In your startup code for the form you will need to register the JavaBean with Forms to do this call the FBean.Register_Bean procedure, passing the class of the Hyperlink Bean which is oracle.forms.demos.beans.Hyperlink

 FBEAN.REGISTER_BEAN('CTL.HyperLink',1,'oracle.forms.demos.beans.Hyperlink');

The first argument to FBean.Register_Bean is the name or id of the bean area.  The second parameter defines the instance of the control that you wish to set the property on (in the UI as opposed to the instance in the block in terms of record number  You can use the constant FBean.ALL_ROWS to register the hyperlink with all bean area instances on the UI at once   The third argument is the class of the Hyperlink JavaBean that you are registering - This value is case sensitive.

Setting up the Hyperlink

Once the Hyperlink is registered you can call the following methods on it:

Property Valid Values / Return Value Purpose
setLabel String String to be displayed as the label of this instance of the item
getLabel String Gets the current Label
setURL String A value which represents the action of the Hyperlink when the user clicks on it.  This is the value that will be passed back as the DATA parameter with the Hyperlink selection event
getURL String Gets the current value for URL
setNormalColor String in format "R G B" Sets the normal color if the Link
getNormalColor String in format "R G B" Gets the normal color if the Link
setActiveColor String in format "R G B" Sets the color if the Link when the mouse moves over it
setActiveColor String in format "R G B" Sets the color if the Link when the mouse moves over it
setVisitedColor String in format "R G B" Sets the color if the Link to be used once it has been visited for the first time
getVisitedColor String in format "R G B" Gets the color if the Link to be used once it has been visited for the first time

Each of these methods is called using Fbean.Invoke or FBean.Invoke_Char.\

In order for the click event from the mouse to be propagated back to Forms you also have to use FBean to enable this event to be communicated from the client to the server.   This uses Fbean.Enable_Event() to enable the ActionListener for the bean

FBean.Enable_Event('Control.Hyperlink',1,'actionListener',true);

When the user clicks on the hyperlink, two things will happen.  Firsty the color will be re-set to the designated Visited Color, then a When-Custom-Item-Event trigger will be raised for the Bean Area in the Form.

You can get the URL value of the clicked hyperlink by using the following code in your When-Custom-Item-Event trigger:

declare 
  vcEventData VARCHAR2(256 char);
  iParamType   PLS_INTEGER;
begin
  GET_PARAMETER_ATTR(:SYSTEM.CUSTOM_ITEM_EVENT_PARAMETERS,'DATA',iParamType,vcEventData);
  
  -- And show that as a Real url
  Web.Show_Document(vcEventData,'_blank');
end;