Author: manaRH
Date: 2013-02-21 07:51:55 -0500 (Thu, 21 Feb 2013)
New Revision: 15418
Modified:
branches/enterprise/WFK-2_1/jboss-seam/src/main/java/org/jboss/seam/mock/MockExternalContext.java
Log:
JBSEAM-5045 Ajax error should call ExceptionFilter too
Modified:
branches/enterprise/WFK-2_1/jboss-seam/src/main/java/org/jboss/seam/mock/MockExternalContext.java
===================================================================
---
branches/enterprise/WFK-2_1/jboss-seam/src/main/java/org/jboss/seam/mock/MockExternalContext.java 2013-02-21
09:37:31 UTC (rev 15417)
+++
branches/enterprise/WFK-2_1/jboss-seam/src/main/java/org/jboss/seam/mock/MockExternalContext.java 2013-02-21
12:51:55 UTC (rev 15418)
@@ -8,7 +8,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.Principal;
@@ -22,18 +21,17 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Level;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import javax.faces.context.PartialResponseWriter;
-import javax.faces.context.ResponseWriter;
import javax.servlet.ServletContext;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.dom4j.Document;
+import org.dom4j.DocumentFactory;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.util.EnumerationIterator;
@@ -56,7 +54,7 @@
public MockExternalContext()
{
- this.context = new MockServletContext();
+ this.context = new MockServletContext();
this.request = new MockHttpServletRequest(new MockHttpSession(context));
this.response = new MockHttpServletResponse();
}
@@ -546,17 +544,12 @@
this.response.setCharacterEncoding("UTF-8");
this.response.addHeader("Cache-Control", "no-cache");
this.response.setStatus(HttpServletResponse.SC_OK);
-
- FacesContext facesContext = FacesContext.getCurrentInstance();
- PartialResponseWriter pwriter =
facesContext.getPartialViewContext().getPartialResponseWriter();
-
- if (pwriter == null)
- {
- pwriter = createPartialResponseWriter();
- }
- pwriter.startDocument();
- pwriter.redirect(url);
- pwriter.endDocument();
+
+ final Document body =
DocumentFactory.getInstance().createDocument("UTF-8");
+
body.addElement("partial-response").addElement("redirect").addAttribute("url",
url);
+
+ this.response.getWriter().format(body.asXML());
+ this.response.getWriter().flush();
}
else
{
@@ -566,38 +559,6 @@
FacesContext.getCurrentInstance().responseComplete();
}
- private PartialResponseWriter createPartialResponseWriter()
- {
- FacesContext facesCtx = FacesContext.getCurrentInstance();
- ExternalContext externalCtx = facesCtx.getExternalContext();
- String encoding = externalCtx.getRequestCharacterEncoding();
- externalCtx.setResponseCharacterEncoding(encoding);
- ResponseWriter responseWriter = null;
- Writer outputWriter = null;
- try
- {
- outputWriter = externalCtx.getResponseOutputWriter();
- }
- catch (IOException ioe)
- {
- log.error("couldn't get ResponseOutputWriter for Partial Ajax
request", ioe);
- }
-
- if (outputWriter != null)
- {
- responseWriter = facesCtx.getRenderKit().createResponseWriter(outputWriter,
"text/xml", encoding);
- }
- if (responseWriter instanceof PartialResponseWriter)
- {
- return (PartialResponseWriter) responseWriter;
- }
- else
- {
- return new PartialResponseWriter(responseWriter);
- }
-
- }
-
@Override
public void setRequest(Object myrequest)
{