viernes, 2 de mayo de 2008

Personalizar skins de Oracle

Tomar un skin de Oracle que aplica para Faces, es decir, ADF en JDeveloper:
  1. Descargar el adffaces_skin.war de los howtos de Oracle
  2. Puede guiarse por este tutorial
  3. Montar el .war en JDeveloper como proyecto nuevo, a partir de un WAR File
  4. Instalar las TAG LIBBRARIES al proyecto: JSF Core y JSF Html. como inidica el tutorial
  5. Tomar la CSS de un proyecto por defecto de faces para tener todos los estilos (1431 líneas y no 731 que trae el .war) y las imágenes (139 y no 73 que trae el .war) de la css: JDEVELOPER10.1.3.3/jdev/extensions/skins/mycompany/myCompanySkin.css y
    JDEVELOPER10.1.3.3/jdev/extensions/skins/mycompany/skin_images
  6. Para cambiar de skin se requieren los siguientes archivos en el WEB-INF:
    adf-faces-config.xml, que viene en el war y se define el skin a utilizar (oracle | mycompany) y adf-faces-skin-xml que no viene con el war
  7. El archivo adf-faces-skin.xml contiene:
  8. Para que los cambios se realicen bien, se debe tener presente la tipografía que trae el JDK por defecto, como lo recomienda Metalink:

    Applies to:

    Oracle JDeveloper - Version: 10.1.3
    This problem can occur on any platform.

    Symptoms


    You developed an ADF Faces application in JDeveloper 10.1.3 on Windows.
    You defined a custom skin "myCustom.css", including, among others the following styles for
    your buttons:

    .AFButtonServerText:alias
    {
    color:black;
    background-color: #D2DEED;
    font-weight:bold;
    font-family: Arial, Helvetica;
    font-size: 11px;
    }

    .AFButtonServerTextDisabled:alias
    {
    color:#AAAAAA;
    font-family:Arial, Helvetica;
    font-size: 11px;
    font-weight: normal;
    }


    When you run the application in the Embedded OC4J on Windows, the page renders correctly, with the
    buttons generated as "image buttons".

    However, the same application deployed on iAS on your Linux machine shows the buttons as standard
    HTML buttons.
    You use the following Java Option in iAS on Linux:
    -Djava.awt.headless=true

    as recommended in the JDeveloper online help, "About ADF Faces Supported Platforms"

    Cause

    The font "Arial" is not available on your Operating System.

    The ADF Faces buttons are normally generated as GIF files by the Java's AWT graphics library.
    When the Java API doesn't have access to the specified font, it generates the button as a standard
    HTML button.

    Solution


    Either install the Arial font on your Linux system (the Java API will use it to generate the image buttons)
    or use another font.
    The best choice to avoid the problem when deploying the application on different platform is to specify a logical font (Dialog, SansSerif, ...), that's mapped to an existing physical font on your OS.
    You can find the list of the mapping in \jdk\jre\lib\font.properties
    NB: this name may differ depending on the OS

    F.ex. the "SansSerif" logical font is mapped to the "Lucida Sans" physical font:
    sansserif.plain.latin-1=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1

    and the Lucida font is always installed as part of the JDK (in ...\jre\lib\fonts).
    So you are sure with this solution that the buttons will always be generated as image buttons, whatever the OS you are deploying to.


    NB: though it was written for UIX, most information contained in the chapter "18. Image Generation in ADF UIX" of the "Oracle ADF UIX Developer's Guide" is still valid for ADF Faces.
  9. Siguiendo el tutorial queda una lista desplegable que cambia el skin según se elija
  10. Cambie en mycompany.css todas las Tahoma a Lucida Sans.
  11. Para desplegar el WAR y luego invocar la URL: agregar contexto/faces/sample.jspx