Sourceforge Project Site
 

Selectors

Advanced configuration

Overview

For each action mapping or pipeline, you can define multiple transforms and let stxx choose which ones to use based on a selection criteria. The selection criteria could be a browser's type, request parameter value, a session value, or even time of day. To configure which selector stxx will use, set the stxx.transformSelector.class property to the implementing class.

Stxx comes with a couple of different implementations. Each can have its own configuration properties in stxx.properties.

com.oroad.stxx.util.UserAgentSelector

This selector chooses stylesheets based on matching the client browser's type. You can define a comma-delimited list of strings used to match each browser type in the property stxx.userAgent.BROWSER_TYPE. For example:

stxx.userAgent.MSIE="MSIE 6.0","MSIE 5.0"

defines the browser type "MSIE" to match any user agent that has the string "MSIE 6.0" or "MSIE 5.0".

com.oroad.stxx.util.UserAgentRegexpSelector

This selector is like the previous selector as it chooses stylesheets based on matching the client browser's type, but instead of simply matching strings, it uses Perl 5-compatible regular expressions. Don't forget to use "\\" instead of a single "\" due to "\" having special meaning to properties files. You can define a regular expression that will be used to match each browser type in the property stxx.userAgent.BROWSER_TYPE. For example:

stxx.userAgent.MSIE=.*MSIE [56]\\.[05].*

defines the browser type "MSIE" to match a user agent like "MSIE 6.0", "MSIE 5.0", or "MSIE 5.5".

com.oroad.stxx.util.RequestAttributeSelector

This selector uses the value of a request attribute to select stylesheets. One way to use this selector would be to create a Servlet filter that could try to determine which "theme" is set for the user from the session, but if no theme can be found, use the browser type to try to guess the most appropriate theme. To configure which request attribute it will use, set the stxx.transformSelector.key.

by Don Brown