Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment:

Update formatting and nomenclature

Sometimes you may want to simply Most often, an application may just need to override a template (see Template Loading) or create an alternative template in so that a certain control renders differently. Or, an application many need to add a new template to an existing theme. HoweverOther times, other times you might want to create your own entire an entirely new theme, especially if perhaps because you are planning to build building a rich set of unique and reusable templates for your organization.

...

  • Create a new theme from scratch (hard!)
  • Extend Wrap an existing themeWrap
  • Extend an existing theme

...

Creating a New Theme from Scratch

Tip
titleKeep it simple, Sam!

It's probably never a good idea to create a new theme from scratch.

...

Instead,

...

use the simple theme as a starting point. The simple theme provides

...

just enough foundation to make it easy to create new controls by extending or wrapping the basic controls. Before starting a new theme, be sure to review the source templates for all of the provided themes.

...

The existing themes are your best guide to creating new themes.

Wrapping an Existing Theme

Taking a look at the xhtml theme, we can see that the templates there make extensive use of a wrapping technique. For example, a template might look like:The xhmtl theme provides several good examples of the "wrapping" technique. The simple theme renders the basic control. The xhtml theme "dresses up" many of the controls by adding a header and footer.

Code Block
xml
xml
titleWrapping a control
<#include "/${parameters.templateDir}/xhtml/controlheader.ftl" />
<#include "/${parameters.templateDir}/simple/xxx.ftl" />
<#include "/${parameters.templateDir}/xhtml/controlfooter.ftl" />

This template is simply wrapping the simple theme's existing template with a header and a footer. This is a Wrapping is a great way to add additional behavior around augment the basic HTML elements provided by the simple theme.

Extending an Existing Theme

The theme infrastructure provided by WebWork also allows themes to extend an existing theme. What this means is that a theme may One benefit of object-orientated programming is that it lets us "design by difference." We can extend an object and code only the behavior that changes. Themes provide a similar capability. The subdirectory that hosts a theme can contain a theme.properties with a file. A parent entry that contains the name of the theme that you would like can be added to the property file to designate a theme to extend. For example, the The ajax theme extends the xhtml theme in using this waytechnique.

Code Block
title/template/ajax/theme.properties

parent = xhtml

An extended theme does not need By extending a theme, you are not required to implement every single template that the Tags use expect. Rather, you It only need needs to implement the templates that you wish to override. All change. The other templates will be are loaded from the parent template.