Configuring Component Renderers

Configuring styles with component-renderer plug-ins is similar to configuring domains with view-renderer and edit-renderer plug-ins. To configure styles, create a StylesConfig.xml file in the application component. An example styles configuration is shown below.

Figure 1. An Example of a StylesConfig.xml File
<?xml version="1.0" encoding="ISO-8859-1"?>
<sc:styles
  <sc:style name="sample-style">
    <sc:plug-in name="component-renderer"
                class="sample.SampleComponentRenderer"/>
  </sc:style>

</sc:styles>

While the namespace and element names are different, the styles configuration file is similar in form to DomainsConfig.xml, but there is only one plug-in per style configuration.

There can be any number of style elements within the styles root element. Styles are defined by naming them in the configuration file; there is no need to model them or declare them anywhere else. Unlike a domain definition, the name of a style does not have to be a valid Java identifier; any non-empty string value that is not entirely composed of whitespace characters is acceptable.

On the plug-in element, the name is always component-renderer and the class is the fully qualified name of the Java class for the widget's component-renderer plug-in.

Where more than one StylesConfig.xml file exists in the application (there can be one in each component) and where the same style is defined more than once, the configuration for that named style from the highest priority component will be used. As styles do not form a hierarchy like domains, there is no inheritance behavior in the in the configuration.

Using the name of a style defined in the CDEJ default style configuration will override the configuration. However, the overriding of the CDEJ default styles is not supported in the Cúram application. Take care not to use the name of an existing CDEJ style, as the results may be unpredictable. To avoid accidental overrides, particularly if using generic style names like label, or panel, use a custom naming convention. For example, prefix style names with a string that represents an ad hoc, private namespace: sample::label and sample::panel. The prefix sample:: is not used by the CDEJ, so it can act like a namespace. The double colon has no special meaning in a style name and any separator character(s) can be used. If using this approach, it is best to choose a separator that is different from any separator used for words in the style name to avoid accidental name clashes.