Skip to content

Commit

Permalink
Upgrade to SiteMesh 2.4.4
Browse files Browse the repository at this point in the history
* Use `DefaultFactory` instead of `Grails5535Factory`
* Use `NoDecorator`
* Use `TokenizedHTMLPage` instead of `GrailsTokenizedHTMLPage`
* Remove `Grails5535Factory`, `GrailsTokenizedHTMLPage`
  • Loading branch information
rainboyan committed May 22, 2024
1 parent fa0c7fa commit 6e10fe6
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 471 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,14 +15,16 @@
*/
package org.grails.web.servlet.view;

import java.util.Collections;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Map;

import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;

import com.opensymphony.module.sitemesh.Config;
import com.opensymphony.module.sitemesh.Factory;
import com.opensymphony.module.sitemesh.factory.DefaultFactory;
import com.opensymphony.sitemesh.ContentProcessor;
import com.opensymphony.sitemesh.compatability.PageParser2ContentProcessor;
import org.springframework.beans.factory.DisposableBean;
Expand All @@ -36,7 +38,6 @@
import grails.core.support.GrailsApplicationAware;

import org.grails.web.sitemesh.FactoryHolder;
import org.grails.web.sitemesh.Grails5535Factory;
import org.grails.web.sitemesh.GroovyPageLayoutFinder;
import org.grails.web.sitemesh.SitemeshLayoutView;

Expand Down Expand Up @@ -80,38 +81,33 @@ public void init() {

protected Factory loadSitemeshConfig() {
FilterConfig filterConfig = new FilterConfig() {
private final Map<String, String> customConfig =
Collections.singletonMap("configFile",
"classpath:org/grails/web/sitemesh/sitemesh-default.xml");

@Override
public ServletContext getServletContext() {
return servletContext;
}

@Override
public Enumeration<String> getInitParameterNames() {
return new Enumeration<String>() {
@Override
public boolean hasMoreElements() {
return false;
}

@Override
public String nextElement() {
throw new NoSuchElementException();
}
};
return Collections.enumeration(this.customConfig.keySet());
}

@Override
public String getInitParameter(String name) {
return null;
return this.customConfig.get(name);
}

@Override
public String getFilterName() {
return null;
}
};

Config config = new Config(filterConfig);
Grails5535Factory sitemeshFactory = new Grails5535Factory(config);
DefaultFactory sitemeshFactory = new DefaultFactory(config);
if (servletContext != null) {
servletContext.setAttribute(FACTORY_SERVLET_CONTEXT_ATTRIBUTE, sitemeshFactory);
}
Expand Down
Loading

0 comments on commit 6e10fe6

Please sign in to comment.