HomeOracle Page 2 - Working with Themes and Templates
Switching an Application’s Theme - Oracle
Most experienced programmers understand the advantages of separating the look and feel of an application from the application's logic. Oracle uses HTML DB to accomplish this. This article introduces you to the themes and templates that HTML DB provides. It is excerpted from chapter 6 of the Oracle HTML DB Handbook, written by Lawrence Linnemeyer and Bradley Brown (McGraw-Hill, 2006; ISBN: 0072257687).
Clicking the Switch Theme button on the Themes page shown in Figure 6-1 takes you into a wizard that walks you through the steps necessary to change an application’s current theme. The Switch Theme button is not available if there is only one theme; you must create another before this button will appear.
The first page of the Switch Theme Wizard allows you to select a new theme. The second page verifies the compatibility of the selected theme with the application’s existing pages and objects. The last page asks for confirmation of the switch.
When switching templates, HTML DB accomplishes mappings from one theme to another through template class identifiers. Each template is assigned to a template class in the first section of the template edit page. For instance, a specific button template might be associate with the “Button” or “Button – Alternate 1” class identifier, among others. By checking the compatibility of themes, HTML DB ensures the new theme contains a template of the same class for every class of template being used. For example, if the application has a button that uses a button template with a “Button – Alternate 1” class identifier, HTML DB ensures that the new theme contains a Button template also associated with the “Button – Alternate 1” class.
If the new theme has two or more templates of the same class, you will see “Warning” in the Status column and a pick list in the To Template column on the Verify Theme Compatibility pages, as shown in Figure 6-2. The pick list allows you to select which template you want to map to in the new theme. Note that the columns are actually mislabeled; they are in fact To and From Template, not To and From Template Class. The To and From templates are matched by their corresponding template classes.
If one of the mappings fails, you will see “Error” in the Status column and you will not be allowed to proceed to the next page of the wizard. An error occurs if either a From template is not associated with a template class or a To theme does not have a template of the same class.
To resolve these errors, note the template name, listed under the From Template column, for each one that has an “Error” status. Cancel out of the switch process. This returns you back to the main Themes page. Click on the small Theme Reports tab, just below the breadcrumb menu, and view the Application Templates report for the existing theme. The report lists each template in the theme by theme type along with its name and associated template class. Observe the template classes for the template name noted earlier. If there is no template class listed, that is part of the
Figure 6-2. Theme compatibility
problem. You must edit your existing template and assign a template class to each template and then try the switch again. If a template class is listed for the template, you must have a template with a corresponding template class in your To theme. In the theme you wish to switch to, create a new (or edit an existing) template of the proper type and associate it with the same template class.
When an application is converted from version 1.5 to 1.6 or 2.0, an initial theme will be created from the application’s templates. The templates will not be assigned a template class. If you want to switch templates, you will have to edit each template and assign it a template class.
Creating New Themes
Like the theme-switching process, the process to create a new theme is also accomplished through a wizard. Start the wizard by clicking on the Create Theme button on the Themes page, as shown earlier in Figure 6-1. The first screen of the wizard presents the three options for creating themes: From the HTML DB Repository, From Scratch, and From Export.
HTML DB comes with a repository of a dozen different themes. If you decide to create a theme based on one from the repository, you will be taken to a screen to select from one of the canned themes. After you have created the new theme, you can alter it in any way you would like. If you select the option to create a theme from an export, the wizard will take you through the process of importing an export file from another application. Exporting and importing of applications and their components is covered in Chapter 7. This is the method you would use to copy a theme from one application to another.
If you select to create a theme from scratch, you will be taken to a screen to name your new theme and then an empty theme will be created. This is the method you use if you want to create all your own templates or copy templates from other different themes. When you create new templates, you can copy them from templates in themes in other applications within your workspace. Before version 1.6, it was not possible to copy templates between applications. When you copy a template, you can subscribe to the original template. If changes are made to the original template, you can update the subscribed template. However, if you do update the subscribed template, any modifications you made will be lost. For more information, refer to the upcoming section, “Creating and Copying Templates.”
Versions 1.6 and above allow you to share templates between applications in the same workspace.
Specifying a Theme’s Default Template
Within a theme you can specify a default template for each type of template. When an application uses a theme and a specific template is not specified for an object, that object will use the theme’s corresponding default template. Clicking the name of a theme listed on the Themes page, as shown earlier in Figure 6-1, will navigate you to the Create/Edit Theme page, shown in Figure 6-3. Here, you can select a default template for each type of template. For page- and region-type templates, you may specify several defaults based on the type of page or type of region. Notice there is no place to set a default template for Popup LOVs; this is because only one Popup LOV template is allowed per theme.