From f925e95f0526d33f011dab2aa715f3b2433449a7 Mon Sep 17 00:00:00 2001 From: "Donald J. Brown" Date: Mon, 9 Oct 2006 18:49:38 +0000 Subject: [PATCH] Adding more friendly result constructors and setters, changed xwork dep to beta 1 WW-1463 WW-1453 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@454455 13f79535-47bb-0310-9956-ffa450edef68 --- core/pom.xml | 12 +--- .../struts2/dispatcher/HttpHeaderResult.java | 33 +++++++-- .../struts2/dispatcher/PlainTextResult.java | 16 +++-- .../ServletActionRedirectResult.java | 68 +++++++++++++++---- .../dispatcher/ServletDispatcherResult.java | 9 ++- .../dispatcher/ServletRedirectResult.java | 12 +++- .../struts2/dispatcher/StreamResult.java | 39 +++++++---- .../dispatcher/StrutsResultSupport.java | 22 ++++-- .../struts2/dispatcher/VelocityResult.java | 7 ++ .../struts2/portlet/result/PortletResult.java | 8 +++ .../portlet/result/PortletVelocityResult.java | 8 +++ .../views/freemarker/FreemarkerResult.java | 10 ++- .../freemarker/PortletFreemarkerResult.java | 11 ++- .../apache/struts2/views/xslt/XSLTResult.java | 12 +++- .../jasperreports/JasperReportsResult.java | 27 ++++++-- .../struts2/dispatcher/ChartResult.java | 18 ++++- .../org/apache/struts2/jsf/FacesResult.java | 7 ++ .../struts2/views/tiles/TilesResult.java | 13 +++- pom.xml | 12 +--- 19 files changed, 260 insertions(+), 84 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 8ec679d3d..42e35e800 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -36,20 +36,10 @@ - opensymphony xwork - 2.0-SNAPSHOT + 2.0-beta-1 diff --git a/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java b/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java index b77d878e5..95c0fc93d 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java @@ -75,8 +75,19 @@ public class HttpHeaderResult implements Result { private boolean parse = true; - private Map headers; + private Map headers; private int status = -1; + + public HttpHeaderResult() { + super(); + headers = new HashMap(); + } + + public HttpHeaderResult(int status) { + this(); + this.status = status; + this.parse = false; + } /** @@ -85,10 +96,6 @@ public class HttpHeaderResult implements Result { * @return a Map of all HTTP headers. */ public Map getHeaders() { - if (headers == null) { - headers = new HashMap(); - } - return headers; } @@ -98,8 +105,9 @@ public class HttpHeaderResult implements Result { * @param parse true if HTTP header values should be evaluated agains the ValueStack, false * otherwise. */ - public void setParse(boolean parse) { + public HttpHeaderResult setParse(boolean parse) { this.parse = parse; + return this; } /** @@ -108,8 +116,19 @@ public class HttpHeaderResult implements Result { * @param status the Http status code * @see javax.servlet.http.HttpServletResponse#setStatus(int) */ - public void setStatus(int status) { + public HttpHeaderResult setStatus(int status) { this.status = status; + return this; + } + + /** + * Adds an HTTP header to the response + * @param name + * @param value + */ + public HttpHeaderResult addHeader(String name, String value) { + headers.put(name, value); + return this; } /** diff --git a/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java b/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java index fb53fe715..671eeef44 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java @@ -79,6 +79,13 @@ public class PlainTextResult extends StrutsResultSupport { private String charSet; + public PlainTextResult() { + super(); + } + + public PlainTextResult(String location) { + super(location); + } /** * Set the character set @@ -94,8 +101,9 @@ public class PlainTextResult extends StrutsResultSupport { * * @param charSet The character set */ - public void setCharSet(String charSet) { + public PlainTextResult setCharSet(String charSet) { this.charSet = charSet; + return this; } /* (non-Javadoc) @@ -132,13 +140,13 @@ public class PlainTextResult extends StrutsResultSupport { InputStreamReader reader = null; try { if (charset != null) { - reader = new InputStreamReader(servletContext.getResourceAsStream(location), charset); + reader = new InputStreamReader(servletContext.getResourceAsStream(finalLocation), charset); } else { - reader = new InputStreamReader(servletContext.getResourceAsStream(location)); + reader = new InputStreamReader(servletContext.getResourceAsStream(finalLocation)); } if (reader == null) { - _log.warn("resource at location ["+location+"] cannot be obtained (return null) from ServletContext !!! "); + _log.warn("resource at location ["+finalLocation+"] cannot be obtained (return null) from ServletContext !!! "); } else { char[] buffer = new char[BUFFER_SIZE]; diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java index 712bdcecc..4d4a92072 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java @@ -132,7 +132,28 @@ public class ServletActionRedirectResult extends ServletRedirectResult { protected String actionName; protected String namespace; protected String method; + + private Map requestParameters = new HashMap(); + public ServletActionRedirectResult() { + super(); + } + + public ServletActionRedirectResult(String actionName) { + this(null, actionName, null); + } + + public ServletActionRedirectResult(String actionName, String method) { + this(null, actionName, method); + } + + public ServletActionRedirectResult(String namespace, String actionName, String method) { + super(null); + this.namespace = namespace; + this.actionName = actionName; + this.method = method; + } + protected List prohibitedResultParam = Arrays.asList(new String[] { DEFAULT_PARAM, "namespace", "method", "encode", "parse", "location", "prependServletContext" }); @@ -154,24 +175,26 @@ public class ServletActionRedirectResult extends ServletRedirectResult { method = conditionalParse(method, invocation); } - Map requestParameters = new HashMap(); - ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get( - invocation.getResultCode()); - Map resultConfigParams = resultConfig.getParams(); - for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext(); ) { - Map.Entry e = (Map.Entry) i.next(); - if (! prohibitedResultParam.contains(e.getKey())) { - requestParameters.put(e.getKey().toString(), - e.getValue() == null ? "": - conditionalParse(e.getValue().toString(), invocation)); - } + String resultCode = invocation.getResultCode(); + if (resultCode != null) { + ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get( + resultCode); + Map resultConfigParams = resultConfig.getParams(); + for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext(); ) { + Map.Entry e = (Map.Entry) i.next(); + if (! prohibitedResultParam.contains(e.getKey())) { + requestParameters.put(e.getKey().toString(), + e.getValue() == null ? "": + conditionalParse(e.getValue().toString(), invocation)); + } + } } ActionMapper mapper = ActionMapperFactory.getMapper(); StringBuffer tmpLocation = new StringBuffer(mapper.getUriFromActionMapping(new ActionMapping(actionName, namespace, method, null))); UrlHelper.buildParametersString(requestParameters, tmpLocation, "&"); - location = tmpLocation.toString(); + setLocation(tmpLocation.toString()); super.execute(invocation); } @@ -181,8 +204,9 @@ public class ServletActionRedirectResult extends ServletRedirectResult { * * @param actionName The name */ - public void setActionName(String actionName) { + public ServletActionRedirectResult setActionName(String actionName) { this.actionName = actionName; + return this; } /** @@ -190,8 +214,9 @@ public class ServletActionRedirectResult extends ServletRedirectResult { * * @param namespace The namespace */ - public void setNamespace(String namespace) { + public ServletActionRedirectResult setNamespace(String namespace) { this.namespace = namespace; + return this; } /** @@ -199,7 +224,20 @@ public class ServletActionRedirectResult extends ServletRedirectResult { * * @param method The method */ - public void setMethod(String method) { + public ServletActionRedirectResult setMethod(String method) { this.method = method; + return this; } + + /** + * Adds a request parameter to be added to the redirect url + * + * @param key The parameter name + * @param value The parameter value + */ + public ServletActionRedirectResult addParameter(String key, Object value) { + requestParameters.put(key, String.valueOf(value)); + return this; + } + } diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletDispatcherResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletDispatcherResult.java index 697f3e57c..4efd35227 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ServletDispatcherResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletDispatcherResult.java @@ -88,7 +88,14 @@ public class ServletDispatcherResult extends StrutsResultSupport { private static final Log log = LogFactory.getLog(ServletDispatcherResult.class); - + public ServletDispatcherResult() { + super(); + } + + public ServletDispatcherResult(String location) { + super(location); + } + /** * Dispatches to the given location. Does its forward via a RequestDispatcher. If the * dispatch fails a 404 error will be sent back in the http response. diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java index 16c3b6c41..4b25f230d 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java @@ -24,6 +24,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; import org.apache.struts2.dispatcher.mapper.ActionMapperFactory; +import org.springframework.beans.factory.config.SetFactoryBean; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; @@ -80,14 +81,23 @@ public class ServletRedirectResult extends StrutsResultSupport { protected boolean prependServletContext = true; + public ServletRedirectResult() { + super(); + } + + public ServletRedirectResult(String location) { + super(location); + } + /** * Sets whether or not to prepend the servlet context path to the redirected URL. * * @param prependServletContext true to prepend the location with the servlet context path, * false otherwise. */ - public void setPrependServletContext(boolean prependServletContext) { + public ServletRedirectResult setPrependServletContext(boolean prependServletContext) { this.prependServletContext = prependServletContext; + return this; } /** diff --git a/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java b/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java index 31701b214..a698164b5 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java @@ -83,8 +83,17 @@ public class StreamResult extends StrutsResultSupport { protected String contentLength; protected String contentDisposition = "inline"; protected String inputName = "inputStream"; + protected InputStream inputStream; protected int bufferSize = 1024; + public StreamResult() { + super(); + } + + public StreamResult(InputStream in) { + this.inputStream = in; + } + /** * @return Returns the bufferSize. */ @@ -95,8 +104,9 @@ public class StreamResult extends StrutsResultSupport { /** * @param bufferSize The bufferSize to set. */ - public void setBufferSize(int bufferSize) { + public StreamResult setBufferSize(int bufferSize) { this.bufferSize = bufferSize; + return this; } /** @@ -109,8 +119,9 @@ public class StreamResult extends StrutsResultSupport { /** * @param contentType The contentType to set. */ - public void setContentType(String contentType) { + public StreamResult setContentType(String contentType) { this.contentType = contentType; + return this; } /** @@ -123,8 +134,9 @@ public class StreamResult extends StrutsResultSupport { /** * @param contentLength The contentLength to set. */ - public void setContentLength(String contentLength) { + public StreamResult setContentLength(String contentLength) { this.contentLength = contentLength; + return this; } /** @@ -137,8 +149,9 @@ public class StreamResult extends StrutsResultSupport { /** * @param contentDisposition the Content-disposition header value to use. */ - public void setContentDisposition(String contentDisposition) { + public StreamResult setContentDisposition(String contentDisposition) { this.contentDisposition = contentDisposition; + return this; } /** @@ -151,8 +164,9 @@ public class StreamResult extends StrutsResultSupport { /** * @param inputName The inputName to set. */ - public void setInputName(String inputName) { + public StreamResult setInputName(String inputName) { this.inputName = inputName; + return this; } /** @@ -160,14 +174,15 @@ public class StreamResult extends StrutsResultSupport { */ protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { - InputStream oInput = null; OutputStream oOutput = null; try { - // Find the inputstream from the invocation variable stack - oInput = (InputStream) invocation.getStack().findValue(conditionalParse(inputName, invocation)); - - if (oInput == null) { + if (inputStream == null) { + // Find the inputstream from the invocation variable stack + inputStream = (InputStream) invocation.getStack().findValue(conditionalParse(inputName, invocation)); + } + + if (inputStream == null) { String msg = ("Can not find a java.io.InputStream with the name [" + inputName + "] in the invocation stack. " + "Check the tag specified for this action."); log.error(msg); @@ -212,7 +227,7 @@ public class StreamResult extends StrutsResultSupport { log.debug("Streaming to output buffer +++ START +++"); byte[] oBuff = new byte[bufferSize]; int iSize; - while (-1 != (iSize = oInput.read(oBuff))) { + while (-1 != (iSize = inputStream.read(oBuff))) { oOutput.write(oBuff, 0, iSize); } log.debug("Streaming to output buffer +++ END +++"); @@ -221,7 +236,7 @@ public class StreamResult extends StrutsResultSupport { oOutput.flush(); } finally { - if (oInput != null) oInput.close(); + if (inputStream != null) inputStream.close(); if (oOutput != null) oOutput.close(); } } diff --git a/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java b/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java index 06c621c6c..ac1685f4d 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java @@ -104,11 +104,25 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics { /** The default parameter */ public static final String DEFAULT_PARAM = "location"; - protected boolean parse = true; - protected boolean encode = false; - protected String location; - protected String lastFinalLocation; + private boolean parse; + private boolean encode; + private String location; + private String lastFinalLocation; + public StrutsResultSupport() { + this(null, true, false); + } + + public StrutsResultSupport(String location) { + this(location, false, false); + } + + public StrutsResultSupport(String location, boolean parse, boolean encode) { + this.location = location; + this.parse = parse; + this.encode = encode; + } + /** * The location to go to after action execution. This could be a JSP page or another action. * The location can contain OGNL expressions which will be evaulated if the parse diff --git a/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java b/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java index 3ff382f73..f1b1c9750 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java @@ -86,6 +86,13 @@ public class VelocityResult extends StrutsResultSupport { private static final Log log = LogFactory.getLog(VelocityResult.class); + public VelocityResult() { + super(); + } + + public VelocityResult(String location) { + super(location); + } /** * Creates a Velocity context from the action, loads a Velocity template and executes the diff --git a/core/src/main/java/org/apache/struts2/portlet/result/PortletResult.java b/core/src/main/java/org/apache/struts2/portlet/result/PortletResult.java index b316c6e90..ba33f3348 100644 --- a/core/src/main/java/org/apache/struts2/portlet/result/PortletResult.java +++ b/core/src/main/java/org/apache/struts2/portlet/result/PortletResult.java @@ -57,6 +57,14 @@ public class PortletResult extends StrutsResultSupport { private String contentType = "text/html"; private String title; + + public PortletResult() { + super(); + } + + public PortletResult(String location) { + super(location); + } /** * Execute the result. Obtains the diff --git a/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java b/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java index 668da1e19..74c409317 100644 --- a/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java +++ b/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java @@ -95,6 +95,14 @@ public class PortletVelocityResult extends StrutsResultSupport { private static final Log log = LogFactory .getLog(PortletVelocityResult.class); + public PortletVelocityResult() { + super(); + } + + public PortletVelocityResult(String location) { + super(location); + } + /* (non-Javadoc) * @see org.apache.struts2.dispatcher.StrutsResultSupport#doExecute(java.lang.String, com.opensymphony.xwork2.ActionInvocation) */ diff --git a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java index 28e610a98..8510054ce 100644 --- a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java +++ b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java @@ -106,9 +106,17 @@ public class FreemarkerResult extends StrutsResultSupport { protected String location; private String pContentType = "text/html"; + public FreemarkerResult() { + super(); + } + + public FreemarkerResult(String location) { + super(location); + } - public void setContentType(String aContentType) { + public FreemarkerResult setContentType(String aContentType) { pContentType = aContentType; + return this; } /** diff --git a/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java b/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java index 4d9696c54..49b6b5441 100644 --- a/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java +++ b/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java @@ -65,8 +65,17 @@ public class PortletFreemarkerResult extends StrutsResultSupport { private String pContentType = "text/html"; - public void setContentType(String aContentType) { + public PortletFreemarkerResult() { + super(); + } + + public PortletFreemarkerResult(String location) { + super(location); + } + + public PortletFreemarkerResult setContentType(String aContentType) { pContentType = aContentType; + return this; } /** diff --git a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java index 44babf069..93f496b0b 100644 --- a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java +++ b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java @@ -201,6 +201,11 @@ public class XSLTResult implements Result { templatesCache = new HashMap(); noCache = Settings.get("struts.xslt.nocache").trim().equalsIgnoreCase("true"); } + + public XSLTResult(String stylesheetLocation) { + this(); + setStylesheetLocation(stylesheetLocation); + } /** * @deprecated Use #setStylesheetLocation(String) @@ -209,11 +214,11 @@ public class XSLTResult implements Result { setStylesheetLocation(location); } - public void setStylesheetLocation(String location) { + public XSLTResult setStylesheetLocation(String location) { if (location == null) throw new IllegalArgumentException("Null location"); - System.out.println("location = " + location); this.stylesheetLocation = location; + return this; } public String getStylesheetLocation() { @@ -225,8 +230,9 @@ public class XSLTResult implements Result { * * @param parse */ - public void setParse(boolean parse) { + public XSLTResult setParse(boolean parse) { this.parse = parse; + return this; } public void execute(ActionInvocation invocation) throws Exception { diff --git a/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/JasperReportsResult.java b/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/JasperReportsResult.java index 2d87ec293..af51f92a2 100644 --- a/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/JasperReportsResult.java +++ b/plugins/jasperreports/src/main/java/org/apache/struts2/views/jasperreports/JasperReportsResult.java @@ -128,33 +128,46 @@ public class JasperReportsResult extends StrutsResultSupport implements JasperRe protected String delimiter; protected String imageServletUrl = "/images/"; - + public JasperReportsResult() { + super(); + } + + public JasperReportsResult(String location) { + super(location); + } + public String getImageServletUrl() { return imageServletUrl; } - public void setImageServletUrl(final String imageServletUrl) { + public JasperReportsResult setImageServletUrl(final String imageServletUrl) { this.imageServletUrl = imageServletUrl; + return this; } - public void setDataSource(String dataSource) { + public JasperReportsResult setDataSource(String dataSource) { this.dataSource = dataSource; + return this; } - public void setFormat(String format) { + public JasperReportsResult setFormat(String format) { this.format = format; + return this; } - public void setDocumentName(String documentName) { + public JasperReportsResult setDocumentName(String documentName) { this.documentName = documentName; + return this; } - public void setContentDisposition(String contentDisposition) { + public JasperReportsResult setContentDisposition(String contentDisposition) { this.contentDisposition = contentDisposition; + return this; } - public void setDelimiter(String delimiter) { + public JasperReportsResult setDelimiter(String delimiter) { this.delimiter = delimiter; + return this; } protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { diff --git a/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java b/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java index 832eb6a64..12be078f0 100644 --- a/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java +++ b/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java @@ -42,15 +42,25 @@ public class ChartResult implements Result { private int height; private int width; + public ChartResult() { + super(); + } + + public ChartResult(JFreeChart chart, int height, int width) { + setChart(chart); + this.height = height; + this.width = width; + } /** * Sets the JFreeChart to use. * * @param chart a JFreeChart object. */ - public void setChart(JFreeChart chart) { + public ChartResult setChart(JFreeChart chart) { this.chart = chart; chartSet = true; + return this; } /** @@ -58,8 +68,9 @@ public class ChartResult implements Result { * * @param height the height of the chart in pixels. */ - public void setHeight(int height) { + public ChartResult setHeight(int height) { this.height = height; + return this; } /** @@ -67,8 +78,9 @@ public class ChartResult implements Result { * * @param width the width of the chart in pixels. */ - public void setWidth(int width) { + public ChartResult setWidth(int width) { this.width = width; + return this; } /** diff --git a/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesResult.java b/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesResult.java index 6e8d85df4..a0b4f0a07 100644 --- a/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesResult.java +++ b/plugins/jsf/src/main/java/org/apache/struts2/jsf/FacesResult.java @@ -33,6 +33,13 @@ public class FacesResult extends StrutsResultSupport implements Result { private static final long serialVersionUID = -3548970638740937804L; + public FacesResult() { + super(); + } + + public FacesResult(String location) { + super(location); + } /** * Checks to see if we need to build a new JSF ViewId from the Struts Result * config and then renders the result by delegating to the diff --git a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java index 8a42b38ed..86fedc51e 100644 --- a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java +++ b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java @@ -84,6 +84,13 @@ public class TilesResult extends ServletDispatcherResult { protected ActionInvocation invocation; private DefinitionsFactory definitionsFactory; + public TilesResult() { + super(); + } + + public TilesResult(String location) { + super(location); + } /** * Dispatches to the given location. Does its forward via a RequestDispatcher. If the * dispatch fails a 404 error will be sent back in the http response. @@ -94,7 +101,7 @@ public class TilesResult extends ServletDispatcherResult { * HTTP request. */ public void doExecute(String location, ActionInvocation invocation) throws Exception { - this.location = location; + setLocation(location); this.invocation = invocation; HttpServletRequest request = ServletActionContext.getRequest(); @@ -106,7 +113,7 @@ public class TilesResult extends ServletDispatcherResult { (DefinitionsFactory) servletContext.getAttribute(TilesUtilImpl.DEFINITIONS_FACTORY); // get component definition - ComponentDefinition definition = getComponentDefinition(this.definitionsFactory, request); + ComponentDefinition definition = getComponentDefinition(location, this.definitionsFactory, request); if (definition == null) { throw new ServletException("No Tiles definition found for name '" + location + "'"); } @@ -150,7 +157,7 @@ public class TilesResult extends ServletDispatcherResult { * @param request current HTTP request * @return the component definition */ - protected ComponentDefinition getComponentDefinition(DefinitionsFactory factory, HttpServletRequest request) + protected ComponentDefinition getComponentDefinition(String location, DefinitionsFactory factory, HttpServletRequest request) throws Exception { ComponentDefinitions definitions = factory.readDefinitions(); return definitions.getDefinition(location, deduceLocale(request)); diff --git a/pom.xml b/pom.xml index b0812275d..08de56cf4 100644 --- a/pom.xml +++ b/pom.xml @@ -256,16 +256,6 @@ - - - - opensymphony - xwork - 2.0-SNAPSHOT - - - - snapshots-maven-codehaus @@ -297,7 +287,7 @@ ignore - false + true http://maven.opensymphony.com