Author: musachy Date: Thu Nov 12 06:11:13 2009 New Revision: 835251 URL: http://svn.apache.org/viewvc?rev=835251&view=rev Log: WW-3291 Update sitemesh-plugin to use version 2.4.2 patch provided by Christian Wolfgang Stone
Added: struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreemarkerMapper2DecoratorSelector.java Modified: struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerMapper2DecoratorSelector.java struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerPageFilter.java struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/VelocityPageFilter.java struts/struts2/trunk/plugins/sitemesh/src/main/resources/struts-plugin.xml Modified: struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerMapper2DecoratorSelector.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerMapper2DecoratorSelector.java?rev=835251&r1=835250&r2=835251&view=diff ============================================================================== --- struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerMapper2DecoratorSelector.java (original) +++ struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerMapper2DecoratorSelector.java Thu Nov 12 06:11:13 2009 @@ -41,11 +41,11 @@ * * Won't decorate the output if it finds a "decorator" flag in the request */ -public class FreeMarkerMapper2DecoratorSelector implements DecoratorSelector { +public class FreemarkerMapper2DecoratorSelector implements DecoratorSelector { private final DecoratorMapper decoratorMapper; - public FreeMarkerMapper2DecoratorSelector(DecoratorMapper decoratorMapper) { + public FreemarkerMapper2DecoratorSelector(DecoratorMapper decoratorMapper) { this.decoratorMapper = decoratorMapper; } Modified: struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerPageFilter.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerPageFilter.java?rev=835251&r1=835250&r2=835251&view=diff ============================================================================== --- struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerPageFilter.java (original) +++ struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreeMarkerPageFilter.java Thu Nov 12 06:11:13 2009 @@ -36,7 +36,7 @@ * Core Filter for integrating SiteMesh + Freemarker into * a Java web application. */ -public class FreeMarkerPageFilter extends SiteMeshFilter { +public class FreemarkerPageFilter extends SiteMeshFilter { @Inject(required=false) public static void setFreemarkerManager(FreemarkerManager mgr) { @@ -53,6 +53,6 @@ protected DecoratorSelector initDecoratorSelector(SiteMeshWebAppContext webAppContext) { Factory factory = Factory.getInstance(new Config(filterConfig)); factory.refresh(); - return new FreeMarkerMapper2DecoratorSelector(factory.getDecoratorMapper()); + return new FreemarkerMapper2DecoratorSelector(factory.getDecoratorMapper()); } } Added: struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreemarkerMapper2DecoratorSelector.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreemarkerMapper2DecoratorSelector.java?rev=835251&view=auto ============================================================================== --- struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreemarkerMapper2DecoratorSelector.java (added) +++ struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/FreemarkerMapper2DecoratorSelector.java Thu Nov 12 06:11:13 2009 @@ -0,0 +1,63 @@ +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.struts2.sitemesh; + +import com.opensymphony.module.sitemesh.mapper.AbstractDecoratorMapper; +import com.opensymphony.module.sitemesh.Decorator; +import com.opensymphony.module.sitemesh.Page; +import com.opensymphony.module.sitemesh.DecoratorMapper; +import com.opensymphony.sitemesh.DecoratorSelector; +import com.opensymphony.sitemesh.Content; +import com.opensymphony.sitemesh.SiteMeshContext; +import com.opensymphony.sitemesh.compatability.Content2HTMLPage; +import com.opensymphony.sitemesh.compatability.OldDecorator2NewDecorator; +import com.opensymphony.sitemesh.webapp.SiteMeshWebAppContext; +import com.opensymphony.sitemesh.webapp.decorator.NoDecorator; + +import javax.servlet.http.HttpServletRequest; + +/** + * Returns a {...@link OldDecorator2NewStrutsFreemarkerDecorator} decorator + * for a Freemarker request. + * + * Won't decorate the output if it finds a "decorator" flag in the request + */ +public class FreemarkerMapper2DecoratorSelector implements DecoratorSelector { + + private final DecoratorMapper decoratorMapper; + + public FreemarkerMapper2DecoratorSelector(DecoratorMapper decoratorMapper) { + this.decoratorMapper = decoratorMapper; + } + + public com.opensymphony.sitemesh.Decorator selectDecorator(Content content, SiteMeshContext context) { + SiteMeshWebAppContext webAppContext = (SiteMeshWebAppContext) context; + HttpServletRequest request = webAppContext.getRequest(); + com.opensymphony.module.sitemesh.Decorator decorator = + decoratorMapper.getDecorator(request, new Content2HTMLPage(content, request)); + if (decorator == null || decorator.getPage() == null) { + return new NoDecorator(); + } else { + return new OldDecorator2NewStrutsFreemarkerDecorator(decorator); + } + } +} Modified: struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/VelocityPageFilter.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/VelocityPageFilter.java?rev=835251&r1=835250&r2=835251&view=diff ============================================================================== --- struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/VelocityPageFilter.java (original) +++ struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/VelocityPageFilter.java Thu Nov 12 06:11:13 2009 @@ -52,7 +52,7 @@ // TODO: Remove heavy coupling on horrible SM2 Factory Factory factory = Factory.getInstance(new Config(filterConfig)); factory.refresh(); - return new FreeMarkerMapper2DecoratorSelector(factory.getDecoratorMapper()); + return new FreemarkerMapper2DecoratorSelector(factory.getDecoratorMapper()); } } Modified: struts/struts2/trunk/plugins/sitemesh/src/main/resources/struts-plugin.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/sitemesh/src/main/resources/struts-plugin.xml?rev=835251&r1=835250&r2=835251&view=diff ============================================================================== --- struts/struts2/trunk/plugins/sitemesh/src/main/resources/struts-plugin.xml (original) +++ struts/struts2/trunk/plugins/sitemesh/src/main/resources/struts-plugin.xml Thu Nov 12 06:11:13 2009 @@ -26,6 +26,6 @@ "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> - <bean class="org.apache.struts2.sitemesh.FreeMarkerPageFilter" static="true" optional="true"/> + <bean class="org.apache.struts2.sitemesh.FreemarkerPageFilter" static="true" optional="true"/> <bean class="org.apache.struts2.sitemesh.VelocityPageFilter" static="true" optional="true"/> </struts>