Author: mrdon
Date: Thu Dec 7 21:52:10 2006
New Revision: 483839
URL: http://svn.apache.org/viewvc?view=rev&rev=483839
Log:
Moving sitemesh decorator over to sitemesh plugin, changing debug interceptor
to only store stack in
session when first invoked, documentation updates to code behind plugin
WW-1546 WW-1483
Added:
struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/NoneDecoratorMapper.java
Removed:
struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/sitemesh/
Modified:
struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/sitemesh.xml
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java
struts/struts2/trunk/plugins/codebehind/src/main/resources/struts-plugin.xml
Modified:
struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/sitemesh.xml
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/sitemesh.xml?view=diff&rev=483839&r1=483838&r2=483839
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/sitemesh.xml
(original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/WEB-INF/sitemesh.xml Thu
Dec 7 21:52:10 2006
@@ -42,7 +42,7 @@
<mapper
class="com.opensymphony.module.sitemesh.mapper.FileDecoratorMapper">
</mapper>
- <mapper
class="org.apache.struts2.showcase.sitemesh.NoneDecoratorMapper">
+ <mapper class="org.apache.struts2.sitemesh.NoneDecoratorMapper">
</mapper>
<mapper
class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper">
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java?view=diff&rev=483839&r1=483838&r2=483839
==============================================================================
---
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
(original)
+++
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
Thu Dec 7 21:52:10 2006
@@ -40,6 +40,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.views.freemarker.FreemarkerManager;
import org.apache.struts2.views.freemarker.FreemarkerResult;
import org.apache.struts2.StrutsConstants;
@@ -105,11 +106,19 @@
private boolean enableXmlWithConsole = false;
private boolean devMode;
+ private FreemarkerManager freemarkerManager;
+
+ private boolean consoleEnabled = false;
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
this.devMode = "true".equals(mode);
}
+
+ @Inject
+ public void setFreemarkerManager(FreemarkerManager mgr) {
+ this.freemarkerManager = mgr;
+ }
/**
* Unused.
@@ -145,6 +154,7 @@
}
});
} else if (CONSOLE_MODE.equals(type)) {
+ consoleEnabled = true;
inv.addPreResultListener(
new PreResultListener() {
public void beforeResult(ActionInvocation inv,
String actionResult) {
@@ -160,6 +170,7 @@
ActionContext.getContext().put("debugXML",
xml);
FreemarkerResult result = new
FreemarkerResult();
+ result.setFreemarkerManager(freemarkerManager);
result.setContentType("text/html");
result.setLocation("/org/apache/struts2/interceptor/debugging/console.ftl");
result.setParse(false);
@@ -175,6 +186,7 @@
ValueStack stack = (ValueStack)
ctx.getSession().get(SESSION_KEY);
String cmd = getParameter(EXPRESSION_PARAM);
+ ServletActionContext.getRequest().setAttribute("decorator",
"none");
HttpServletResponse res = ServletActionContext.getResponse();
res.setContentType("text/plain");
@@ -193,7 +205,7 @@
try {
return inv.invoke();
} finally {
- if (devMode) {
+ if (devMode && consoleEnabled) {
final ActionContext ctx = ActionContext.getContext();
ctx.getSession().put(SESSION_KEY,
ctx.get(ActionContext.VALUE_STACK));
}
Modified:
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java?view=diff&rev=483839&r1=483838&r2=483839
==============================================================================
---
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java
(original)
+++
struts/struts2/trunk/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java
Thu Dec 7 21:52:10 2006
@@ -48,6 +48,9 @@
import com.opensymphony.xwork2.config.providers.InterceptorBuilder;
import com.opensymphony.xwork2.inject.Inject;
+/**
+ * Uses code-behind conventions to solve the two unknown problems.
+ */
public class CodebehindUnknownHandler implements UnknownHandler {
protected String defaultPackageName = "codebehind-default";
Modified:
struts/struts2/trunk/plugins/codebehind/src/main/resources/struts-plugin.xml
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/codebehind/src/main/resources/struts-plugin.xml?view=diff&rev=483839&r1=483838&r2=483839
==============================================================================
---
struts/struts2/trunk/plugins/codebehind/src/main/resources/struts-plugin.xml
(original)
+++
struts/struts2/trunk/plugins/codebehind/src/main/resources/struts-plugin.xml
Thu Dec 7 21:52:10 2006
@@ -3,7 +3,7 @@
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
-
+
<struts>
<bean type="com.opensymphony.xwork2.UnknownHandler"
class="org.apache.struts2.codebehind.CodebehindUnknownHandler" />
Added:
struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/NoneDecoratorMapper.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/NoneDecoratorMapper.java?view=auto&rev=483839
==============================================================================
---
struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/NoneDecoratorMapper.java
(added)
+++
struts/struts2/trunk/plugins/sitemesh/src/main/java/org/apache/struts2/sitemesh/NoneDecoratorMapper.java
Thu Dec 7 21:52:10 2006
@@ -0,0 +1,41 @@
+/*
+ * $Id: FreeMarkerPageFilter.java 475637 2006-11-16 08:32:03Z mrdon $
+ *
+ * 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 javax.servlet.http.HttpServletRequest;
+
+/**
+ * Won't decorate the output if it finds a "decorator" flag in the request
+ */
+public class NoneDecoratorMapper extends AbstractDecoratorMapper {
+
+ public Decorator getDecorator(HttpServletRequest req, Page page) {
+ if ("none".equals(req.getAttribute("decorator"))) {
+ return null;
+ }
+
+ return super.getDecorator(req, page);
+ }
+}
\ No newline at end of file