Wednesday, 17 February 2010

Implement Forms look and feel


First download the zip file from this site on Sources&doc.
Depending of the Forms version you use, copy the corresponding JAR file to  your /forms/java folder.
You also have to add the JAR file name to the archive tag of your /forms/server/formsweb.cfg configuration file.
...
archive=frmall.jar,laf_1012.jar
...

note:
We update the archive tag and not the archive_jini because this tool uses methods available in the 1.4 JRE, so it won't run with the Jinitiator.


Copy the forms.css file on your server, there is a parameter in forms PM$CSS_FILENAME where you specify where the css file is.

To implement in existing forms use LAF_JDAPI tool.
 
To implement in new modules you must use the template form:

In the /fmb folder of the zip file, you would find a template named LAF_TEMPLATE.fmb.
While you are building a brand new module from scratch, it is best to create the new module from this template, by using the File → New → Forms using template... Forms Builder menu option.
Every component needed to use the LAF features will be incorporated.

The /css sub-folder contains the current forms.css template CSS file.

There are several places you can indicate the location of this file.
The PM$CSS_FILENAME Forms parameter is one of them.
If you create a new module from the LAF_TEMPLATE.fmb file or if you use the GRP_LAF laf.olb Object Library group, it would be present in your module.
You can also indicate the full path directly in the
PKG_Look_And_Feel.Open_Css() laf.pll's function.

The /pll folder that contains the laf.pll PL/SQL library.
It is required to attach this library to your Forms modules, if you want to use the CSS feature like painting the canvas or the blocks.

The /scripts folder contains some scripts to maintain the Database
objects:
PKG_LAF.sql
PKG_DB_LAF_LOV.sql
 
Example of plsql code of when-timer-expired form trigger:

Begin   

  If lower(Get_Application_Property( TIMER_NAME )) = 'laf_timer' Then
    Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'CLEAR', '' );
      -------------------------------------
      --    form main initializations    --
      -------------------------------------
     ---------------------------------------------------------------------------
   -- global settings
   -- that could be read from the CSS file
   -- in a section of type : gui
   --
   Set_Custom_Property( 'LAF_BLOCK.LAF_BEAN', 1, 'SET_SCHEME', 'blue' ) ;
   --Set_Custom_Property( 'LAF_BLOCK.LAF_BEAN', 1, 'SET_FOCUS_BACKGROUND', 'true' ) ;
   --Set_Custom_Property( 'LAF_BLOCK.LAF_BEAN', 1, 'SET_APPLY_SCHEME', 'frame,true' ) ;
   --Set_Custom_Property( 'LAF_BLOCK.LAF_BEAN', 1, 'SET_APPLY_SCHEME', 'menu,true' ) ;
   --Set_Custom_Property( 'LAF_BLOCK.LAF_BEAN', 1, 'SET_APPLY_SCHEME', 'window,true' ) ;
   --Set_Custom_Property( 'LAF_BLOCK.LAF_BEAN', 1, 'SET_APPLY_SCHEME', 'status,true' ) ;
   -- apply those changes --
   --Set_Custom_Property( 'LAF_BLOCK.LAF_BEAN', 1, 'DRAW_GUI_ELEMENTS', '' ) ;
   ---------------------------------------------------------------------------
   -- draw the frames --
   Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME','F1,1,Buscar solicitudes,Arial,12,B,top,left') ;
   Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME_BOUNDS','F1,15,12,620,57');
   Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME_ROUND_BORDER','F1,true') ;
   Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME_BACKGROUND','F1,r255g255b255,r60g138b255') ;


  Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME','F2,1,Solicitudes,Arial,12,B,top,left') ;
  Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME_BOUNDS','F2,15,80,940,170');
  Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME_ROUND_BORDER','F2,true') ;
  Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME_BACKGROUND','F2,r255g255b255,r60g138b255') ;
 
  Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME','F3,1,Seguimiento de la Solicitud,Arial,12,B,top,left') ;
  Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME_BOUNDS','F3,160,260,590,190');
  Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME_ROUND_BORDER','F3,true') ;
  Set_Custom_Property('LAF_BLOCK.LAF_BEAN',1,'SET_FRAME_BACKGROUND','F3,r255g255b255,r60g138b255') ;
 
 
 
      If PKG_Look_And_Feel.Open_Css(:PARAMETER.PM$CSS_FILENAME) Then
   
        -- read the global GUI properties --
        PKG_LOOK_AND_FEEL.Set_GUI_Properties( '.GUIPropertiesBlue', 'LAF_BLOCK.LAF_BEAN' ) ;
     
        -- paint the canevases --
        PKG_LOOK_AND_FEEL.Paint_Canevas(:PARAMETER.PM$CANVAS, 'LAF_BLOCK.LAF_BEAN' ) ;
   
        /**/
        -- paint the blocks --
        PKG_LOOK_AND_FEEL.Paint_Block
        (
          PC$Block      => 'B1'
         ,PC$BeanName   => 'LAF_BLOCK.LAF_BEAN'
         ,PC$VA_Name    => :PARAMETER.PM$VA
         ,PC$HeadClass  => :PARAMETER.PM$HEADER
         ,PC$BodyClass  => :PARAMETER.PM$BODY
         ,PC$TitleClass => :PARAMETER.PM$TITLE
         ,PC$Title      => 'Buscar Solicitudes'
         ,PB$ScrollBar  => True
        ) ;

        /**/

      -- paint the blocks --
        PKG_LOOK_AND_FEEL.Paint_Block
        (
          PC$Block      => 'SSO'
         ,PC$BeanName   => 'LAF_BLOCK.LAF_BEAN'
         ,PC$VA_Name    => :PARAMETER.PM$VA
         ,PC$HeadClass  => :PARAMETER.PM$HEADER
         ,PC$BodyClass  => :PARAMETER.PM$BODY
         ,PC$TitleClass => null --:PARAMETER.PM$TITLE
         ,PC$Title      => null --'Solicitudes'
         ,PB$ScrollBar  => True
        ) ;       

        PKG_LOOK_AND_FEEL.Paint_Block
        (
          PC$Block      => 'SSSO'
         ,PC$BeanName   => 'LAF_BLOCK.LAF_BEAN'
         ,PC$VA_Name    => :PARAMETER.PM$VA
         ,PC$HeadClass  => :PARAMETER.PM$HEADER
         ,PC$BodyClass  => :PARAMETER.PM$BODY
         ,PC$TitleClass => null --:PARAMETER.PM$TITLE
         ,PC$Title      => null --'Solicitudes'
         ,PB$ScrollBar  => True
        ) ;       
      
        go_block('B1');
      
      End if ;


  End if ;

In parameter PM$CSS_FILENAME i have this value /opt/oracle/css/forms.css where my css file is on my oas.

And you must have this items LAF_BEAN and BEAN_LOV of block LAF_BLOCK on each canvas that you want to apply the css style.
For example if i have 2 canvas i have one block laf_block with items laf_bean and bean_lov on canvas 1, and another block laf_block2 with items laf_bean and bean_lov on canvas 2.




Oracle Reports to Excel Output

1) Create an xls template
This template will contains generic information as the title , logo, column header, etc.
And a simple line of data with sample values, this is to ensure that the correct formatting is performed for the different datatypes.
Save the xls spreadsheet as a web page (File -> save as web page (htm or html)).

2) Open the web page in reports builder
Open the web page in reports builder and double click on Web Source to display the html code for the excel spreadsheet. Add a datasource to the report, click on data model icon and click the sql to create a data source based on a sql query:

select cod_provincia, cod_prestacion, descripcion, estado, cantidad
from   table

3) Modify the Web Source
Now you need to modify the web source to tell reports builder to display your report in excel.
To force the browser to open MS Excel it is necessary to change the HTTP Content Type to a specific MIME Type: application/vnd.ms-excel

<%@ taglib uri="/WEB-INF/lib/reports_tld.jar" prefix="rw" %>
<%@ page language="java" import="java.io.*" errorPage="/rwerror.jsp" session="false" %>
<%@ page contentType="application/vnd.ms-excel" %>
<rw:report id="reportJsp" >
<rw:objects id="objects">
</rw:objects>

To respect excel format you need to delete the blank lines above the <html> tag:
<%@ taglib uri="/WEB-INF/lib/reports_tld.jar" prefix="rw" %>
<%@ page language="java" import="java.io.*" errorPage="/rwerror.jsp" session="false" %>
<%@ page contentType="application/vnd.ms-excel" %>
<rw:report id="reportJsp" >
<rw:objects id="objects">
</rw:objects>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

Now you are going to add the data retrieved by your sql query to the report:
Search for the example data that you write on the excel template, and then add a repeating frame:

<rw:foreach id="gCodProvinciaId" src="G_COD_PROVINCIA">
 <tr height=18 style='height:13.5pt'>
  <td height=18 style='height:13.5pt'></td>
  <td class=xl27><rw:field id="codPrestacionId" src="COD_PRESTACION"> &Field </rw:field></td>
  <td class=xl27><rw:field id="descripcionId" src="DESCRIPCION"> &Field </rw:field></td>
  <td class=xl27><rw:field id="estadoId" src="ESTADO"> &Field </rw:field></td>
  <td class=xl26 align=right><rw:field id="cantidadId" src="CANTIDAD"> &Field </rw:field></td>
 </tr>
</rw:foreach>

In the opening repeating tag for each add the name of the report group. And then map the cells of the excel spreadsheet to the corresponding field from your data model.

I also add a summary on my report on field cantidad and after </rw:foreach> I show this summary like this:

<tr height=17 style='height:12.75pt'>
  <td height=17 style='height:12.75pt'></td>
  <td class=xl27> </td>
  <td class=xl27> </td>
  <td class=xl27> </td>
  <td class=xl35><rw:field id="totalId" src="total"> &Field </rw:field></td>
 </tr>

Then I save the report as a Report JSP

4) Test the report
You can now test the report using the run web layout icon in the toolbar.
This execution creates a temporary HTML file and launches the browser. To launch excel from the browser you need to test it from Report Server.
First start report server and then copy the jsp report to: ids_home/reports/j2ee/reports_ids/web/test

Then I need to call my report from a form that runs on oracle application server 10.1.2 on Suse 10, so I was wondering how to deploy a jsp report on the web and I found the Metalink note 220943.1.
And I chose the simplest way that is to deploy my jsp report in the reports application.   
You copy the JSPs under the         $Oracle_Home/j2ee/OC4J_BI_Forms/applications/reports/web,
you can create subdirectories.
 
And the code on my form to call my jsp report is :
 
web.show_document('/reports/test.jsp?'||'keyxxx'|| 
'&p_cod_provincia='||nvl(:b1.cod_provincia,0)||
'&p_d_provincia='||:b1.descripcion
);