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.configWeb directory which contains the javascript and the css file
directory.cssWeb directory which contains the css file for the skin. If unset, default to the value of directory.config
directory.imagesWeb directory which contains the images used by this skin
skinName of the css file to use with this skin
display.null.fieldsIf set to false, empty fields are not displayed in inspect mode
follow.changeIf set to false, a warning message will be displayed if a link is selected on a page having form changes
panel.classImplementation of the panel interface to use
collection.classImplementation of the collection interface to use
tabs.classImplementation of the tabbed panel interface to use
field.classImplementation of the field interface to use
pager.classImplementation of the pager interface to use
treeview.classImplementation of the treeview interface to use
crumb.classImplementation of the crumb renderer to use
toolbar.classImplementation of the toolbar renderer to use
formatter.classImplementation of the formatter to use
policy.classImplementation of the policy to use
layout.sortName of the picture to show to indicate a column is sortable. If set to "none", no picture is shown. Default: sort.gif
layout.sort.forwardName of the picture to show to indicate a column is sorted in ascending order. Default : sort.gif
layout.sort.reverseName of the picture to show to indicate a colimn is sorted in descending order. Default : sort.gif
layout.sort.labelText to associate with the previous picture
layout.pager.previous.imgName of the picture to show to navigate to the previous page
layout.pager.previous.labelText to associate with the previous picture
layout.pager.next.imgName of the picture to show to navigate to the next page
layout.pager.next.labelText to associate with the previous picture
layout.pager.maxPageItemsMaximum number of items per page
layout.pager.maxLinksMaximum number of links to page to display
layout.pager.displayDirectIf set to true, display an input field after the pager to navigate to a specified page
layout.checkbox.checkedImage displayed in inspect mode when a checkbox is selected
layout.checkbox.checked.labelText to associate with the previous picture
layout.checkbox.uncheckedImage displayed in inspect mode when a checkbox is not selected
layout.checkbox.unchecked.labelText to associate with the previous picture
layout.calendarCalendar image displayed on the right of the date tag
link.token.includeInclude a transaction token in all links
nested.compatibilityStruts nested compatibility. Default is false.
sort.error.keepShould errors be redisplay after a sort/page action. Default is true.
sort.token.requiredRequire 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.actionPath of the Struts-Layout sort action. Default is sort.do
styleclass.collectionDefault styleClass for the collection tag (default is null)
styleclass.panelDefault styleClass for the panel tag (default is null)
styleclass.labelDefault styleClass for the input field tags (default is null)
styleclass.gridDefault styleClass for the grid tag (default is null)
styleclass.pagerDefault styleClass for the pager tag (default is null)
styleclass.layerDefault styleClass for the layer tag (default is null)
error.displayDisplay error messages next to the input fields. Default: true
error.focusSet the focus on the first error field. Default is false.
error.formatFormat error messages using errors.header, errors.footer, errors.prefix and errors.suffix properties. Default: false
field.helpPosition of the field help. Possibles values: AFTER_LABEL, AFTER_FIELD (default is AFTER_FIELD)
field.helperName of the picture to show the field helper. Default is "loupe.gif"
tree.numberOfMenusLoadedNumber of menus to load at once in the treeview. Default is 50.
treeview.actionPath of the Struts-Layout treeview action. Default is treeview.do.
el.characterStruts-Layout EL character. Default is '$'. Change it if your servlet container is interpreting ${} ELs
autoskip.activeEnable skip to next field when a field maxlength is reached. Default if false.
skin.scriptsScripts 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:

			 <plug-in className="fr.improve.struts.taglib.layout.workflow.LayoutPlugin">
			 	<set-property property="skinResources" value="MyDefaultSkin"/>
			 </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");