Skin configuration

Introduction

  • Struts-Layout skins are configured using a properties file. The configurable properties includes the css file name, the image directory, the names of HTML renderers and much more.
  • Struts-Layouts ships with a default properties file, so you don't need to do anything to get a working configuration. However, you will certainly like to use your own CSS file. To add additional skins put additional properties files named "Struts-Layout_<skin name>.properties" in your WEB-INF/classes directory.
  • To associate a skin to an HTTP session, use the static method setSkin(HttpSession session, String skinName) in fr.improve.struts.taglib.layout.util.LayoutUtil.
  • To set the default skin configuration, name the configuration file "Struts-Layout_default.properties".
  • If you don't want your skin configuration files to start with "Struts-Layout" you can set another prefix by using the Struts-Layout plugin.

Configuration properties

directory.config Web directory which contains the javascript and the css file
directory.css Web directory which contains the css file for the skin. If unset, default to the value of directory.config
directory.images Web directory which contains the images used by this skin
skin Name of the css file to use with this skin
display.null.fields If set to false, empty fields are not displayed in inspect mode
follow.change If set to false, a warning message will be displayed if a link is selected on a page having form changes
panel.class Implementation of the panel interface to use
collection.class Implementation of the collection interface to use
tabs.class Implementation of the tabbed panel interface to use
field.class Implementation of the field interface to use
pager.class Implementation of the pager interface to use
treeview.class Implementation of the treeview interface to use
crumb.class Implementation of the crumb renderer to use
toolbar.class Implementation of the toolbar renderer to use
formatter.class Implementation of the formatter to use
policy.class Implementation of the policy to use
layout.sort Name of the picture to show to indicate a column is sortable. If set to "none", no picture is shown. Default: sort.gif
layout.sort.forward Name of the picture to show to indicate a column is sorted in ascending order. Default : sort.gif
layout.sort.reverse Name of the picture to show to indicate a colimn is sorted in descending order. Default : sort.gif
layout.sort.label Text to associate with the previous picture
layout.pager.previous.img Name of the picture to show to navigate to the previous page
layout.pager.previous.label Text to associate with the previous picture
layout.pager.next.img Name of the picture to show to navigate to the next page
layout.pager.next.label Text to associate with the previous picture
layout.pager.maxPageItems Maximum number of items per page
layout.pager.maxLinks Maximum number of links to page to display
layout.pager.displayDirect If set to true, display an input field after the pager to navigate to a specified page
layout.checkbox.checked Image displayed in inspect mode when a checkbox is selected
layout.checkbox.checked.label Text to associate with the previous picture
layout.checkbox.unchecked Image displayed in inspect mode when a checkbox is not selected
layout.checkbox.unchecked.label Text to associate with the previous picture
layout.calendar Calendar image displayed on the right of the date tag
link.token.include Include a transaction token in all links
nested.compatibility Struts nested compatibility. Default is false.
sort.error.keep Should errors be redisplay after a sort/page action. Default is true.
sort.token.required Require a valid token to sort a collection
sort.rules.class Name of the default String SortRules class to use. Default is null.
Different SortRules can be set for different locales by appending the locale in the key like this : sort.rules.fr_fr.class
The following class can be used for Persian sorting : fr.improve.struts.taglib.layout.sort.PersianSortRules,
and this one for French : fr.improve.struts.taglib.layout.sort.FrenchSortRules.
Custom SortRules must implements fr.improve.struts.taglib.layout.sort.SortRules
sortutil.action Path of the Struts-Layout sort action. Default is sort.do
styleclass.collection Default styleClass for the collection tag (default is null)
styleclass.panel Default styleClass for the panel tag (default is null)
styleclass.label Default styleClass for the input field tags (default is null)
styleclass.grid Default styleClass for the grid tag (default is null)
styleclass.pager Default styleClass for the pager tag (default is null)
styleclass.layer Default styleClass for the layer tag (default is null)
error.display Display error messages next to the input fields. Default: true
error.focus Set the focus on the first error field. Default is false.
error.format Format error messages using errors.header, errors.footer, errors.prefix and errors.suffix properties. Default: false
field.help Position of the field help. Possibles values: AFTER_LABEL, AFTER_FIELD (default is AFTER_FIELD)
field.helper Name of the picture to show the field helper. Default is "loupe.gif"
tree.numberOfMenusLoaded Number of menus to load at once in the treeview. Default is 50.
treeview.action Path of the Struts-Layout treeview action. Default is treeview.do.
el.character Struts-Layout EL character. Default is '$'. Change it if your servlet container is interpreting ${} ELs
autoskip.active Enable skip to next field when a field maxlength is reached. Default if false.
skin.scripts Scripts included in every page (default is null).

Using several collection implementation in the same skin:

To use several collection renderer with the same skin, it is possible to add a model name after the property. For example, collection.class.myModel = com.foo.MyCollectionInterface declares a new collection renderer that can be used by setting the model attribute of the collection tag to "myModel".

Using several field implementation in the same skin:

To use several field renderer with the same skin, it is possible to add a model name after the property. For example, field.class.myModel = com.foo.MyFieldInterface declares a new field renderer that can be used by setting the model attribute of the input field tags to "myModel".

Setting default styleClass

To set default value to the styleClass attributes, the following can bed added to the skin configuration file:

  • styleclass.collection = COLLECTION
  • styleclass.panel = PANEL
  • styleclass.label = FIELD
  • styleclass.grid = GRID
  • styleclass.pager = PAGER
  • styleclass.layer = LAYER

Plugin configuration example

To use a different default configuration file, the struts-layout plugin must be initialized. This is done by adding the following code in struts-config.xml:

1             <plug-in className="fr.improve.struts.taglib.layout.workflow.LayoutPlugin">
2                 <set-property property="skinResources" value="MyDefaultSkin"/>
3             </plug-in>

If you're using struts 1.0, plugin extension is not available, and you will need to subclass the struts ActionServlet and add the following code in the init method.

fr.improve.struts.taglib.layout.skin.Skin.setResourcesName("MyDefaultSkin");