1 9 10 package com.opensymphony.module.sitemesh.mapper; 11 12 import com.opensymphony.module.sitemesh.Config; 13 import com.opensymphony.module.sitemesh.Decorator; 14 import com.opensymphony.module.sitemesh.DecoratorMapper; 15 import com.opensymphony.module.sitemesh.Page; 16 17 import javax.servlet.http.HttpServletRequest ; 18 import java.util.Properties ; 19 20 37 public final class PrintableDecoratorMapper extends AbstractDecoratorMapper { 38 private String decorator, paramName, paramValue; 39 40 public void init(Config config, Properties properties, DecoratorMapper parent) throws InstantiationException { 41 super.init(config, properties, parent); 42 decorator = properties.getProperty("decorator"); 43 paramName = properties.getProperty("parameter.name", "printable"); 44 paramValue = properties.getProperty("parameter.value", "true"); 45 } 46 47 public Decorator getDecorator(HttpServletRequest request, Page page) { 48 Decorator result = null; 49 if (decorator != null && paramValue.equalsIgnoreCase(request.getParameter(paramName))) { 50 result = getNamedDecorator(request, decorator); 51 } 52 return result == null ? super.getDecorator(request, page) : result; 53 } 54 } | Popular Tags |