Class AgentDecoratorMapper
- All Implemented Interfaces:
DecoratorMapper
This can be useful for supplying different versions of the same content for different browsers (e.g. vanilla HTML for Lynx, complex tables and frames for Netscape, extra stuff for IE5, etc).
This can also be used to enhance search-engine ratings by using a 'bait and switch' system - this involves showing a search-engine friendly of the content to spiders only.
When AgentDecoratorMapper is in the chain, it will request the appropriate Decorator
from its parent. It will then add an extention to the filename of the Decorator, and
if that file exists it shall be used as the Decorator instead. For example, if the
Decorator path is /blah.jsp
and the detected user-agent is ie
,
the path /blah-ie.jsp
shall be used.
The agent mappings are configured by passing properties with match.
as a prefix.
For example: 'match.MSIE'=ie , 'match.Lynx'=plain .
- Version:
- $Revision: 1.3 $
- Author:
- Joe Walnes
- See Also:
-
Field Summary
FieldsFields inherited from class com.opensymphony.module.sitemesh.mapper.AbstractDecoratorMapper
config, parent
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDecorator
(javax.servlet.http.HttpServletRequest request, Page page) Delegate to parent.private String
Get extention for user-agent.void
init
(Config config, Properties properties, DecoratorMapper parent) Set parent.private void
initMap
(Properties props) Initialize user-agent mappings.private static String
modifyPath
(String path, String ext) Change /abc/def.jsp into /abc/def-XYZ.jspMethods inherited from class com.opensymphony.module.sitemesh.mapper.AbstractDecoratorMapper
getNamedDecorator
-
Field Details
-
map
-
-
Constructor Details
-
AgentDecoratorMapper
public AgentDecoratorMapper()
-
-
Method Details
-
init
public void init(Config config, Properties properties, DecoratorMapper parent) throws InstantiationException Description copied from class:AbstractDecoratorMapper
Set parent.- Specified by:
init
in interfaceDecoratorMapper
- Overrides:
init
in classAbstractDecoratorMapper
- Parameters:
config
- Config supplied by Servlet or Filter.properties
- Any initialization properties (specific to implementation).- Throws:
InstantiationException
- should be thrown if the implementation cannot be initialized properly.
-
getDecorator
Description copied from class:AbstractDecoratorMapper
Delegate to parent.- Specified by:
getDecorator
in interfaceDecoratorMapper
- Overrides:
getDecorator
in classAbstractDecoratorMapper
-
getExt
Get extention for user-agent. -
modifyPath
Change /abc/def.jsp into /abc/def-XYZ.jsp -
initMap
Initialize user-agent mappings.
-