Templates
The real work of rendering widgets is performed by JSP
templates. A widget may be rendered in several different forms called
views. A widget might, for example, have a
default
view and a json
view for
rendering the widget as JSON data rather than HTML. The view that is
actually used in any particular case is determined by the publication
designer, who selects the view inContent Studio. Widgets
with multiple views must therefore always include a
view
option that allows the designer to make this
selection. The view
field that represents this
option should always be included in the General panel of the widget's
content type definition. There should usually also be a panel to hold
the parameters for each view (see Content Type).
The core widgets supplied with the Widget Framework currently
all have only one default
view. Despite this, there
is always a view
field in the widget's General
panel, and a corresponding Default panel, to prepare for possible
future expansion.
Templates are stored in a widget's
src/main/webapp/template/widgets/
widget-name/
folder. This folder contains a view
subfolder that
in turn contains one JSP file for each view supported by the widget.
There may also be a helpers folder containing additional JSP files
used by the main view JSPs.
If a widget has no view
field, then a
default view name is set by the controller framework. The default
view name is default
. It is possible to change
this default view name by setting the
defaultViewName
property in the
DefaultMapController.properties
file. If this
property is not set then default
is used as the
default view name.