External Web Layout Definitions

By default, the layout definitions used to generate a web page are internal to the component, whether it is a static server page (USP) or dynamic server page (DSP). However, it is possible to generate external layout definition files and use these at runtime instead of the internal definition.

External layout definitions enable you to maintain the layout in a third-party tool, or to incorporate the standards and templates for your web site without having to do so in the IDE.

Generating External Layout Definitions

To generate an external layout definition (also known as an HTML skeleton file), compile the server page from the command line using the /ext subswitch. For example:

uniface /usp /ext
uniface /dsp /ext

This generates files for server pages to your working directory, with the default name ServerPageName.hts. For deployment, you can locate these files where you want specify their location in the [FILES] section of the assignment file.

For more information, see /ext

Using External Layout Definitions

At runtime, Uniface can use this file to supply the server page layout, instead of the internally-defined layout. There are several ways that you can instruct Uniface to use the external layout, depending on the type of server page.

Dynamic Server Pages (DSPs)

For DSPs, you can cause Uniface to use the .hts file in the following ways:

  • By specifying the layout file in the weblayout statement (usually used in trigger postActivate):

    weblayout "MyDsp.hts"
  • By using fileload to read the file, and assigning the result to $instancelayout; for example:

    ; Load the stored layout
    fileload/raw "..\layouts\MyDsp.hts", vWebLayout
    
    ; Assign the value to $instancelayout 
    $instancelayout = vWebLayout
    

    The layout in $instancelayout is subsequently used by the weblayout statement when generating the web page.

  • By deleting the internal layout (after generating an .hts file with /ext) and compiling the DSP again (without using /ext). This empties the internal layout of the .dsp file empty, forcing it to fall back to the .hts file.:

    Caution: If you again compile the DSP using /ext after deleting the internal DSP layout, the existing .hts file is overwritten with the empty layout.

Static Server Pages (USPs)

For USPs, you can cause Uniface to use the .hts file in the following ways:

  • By specifying the layout file in the webgen statement; for example:

    webgen "MyUsp.hts"
  • By setting the $SEARCH_SKELETON assignment setting to external_only or external_first; for example:

    ; MyApp.asn
    [SETTINGS]
    $SEARCH_SKELETON = external_first
    
    [FILES]
    *.hts
    
  • By deleting the internal layout (after generating an .hts file with /ext) and compiling the USP again (without using /ext) and setting $SEARCH_SKELETON to internal_first. This also forces Uniface to fall back to the .hts file.

    Caution: If you again compile the USP using /ext after deleting the internal USP layout, the existing .hts file is overwritten with the empty layout.

Related Topics