You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2017/01/26 16:15:06 UTC
svn commit: r1780418 - in
/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main:
java/org/apache/myfaces/tobago/example/demo/bestpractice/
webapp/content/30-concept/24-non-faces-response/
Author: lofwyr
Date: Thu Jan 26 16:15:06 2017
New Revision: 1780418
URL: http://svn.apache.org/viewvc?rev=1780418&view=rev
Log:
TOBAGO-1687: After a Download/Non Faces Response no AJAX is possible
* better sample
Added:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/x-sample.txt
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/non-faces-response.xhtml
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java?rev=1780418&r1=1780417&r2=1780418&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java Thu Jan 26 16:15:06 2017
@@ -43,32 +43,32 @@ public class BestPracticeController {
}
public String viewPdfInBrowser() {
- return viewPdf(false);
+ return viewFile(false, true);
}
public String viewPdfOutsideOfBrowser() {
- return viewPdf(true);
+ return viewFile(true, true);
}
- private String viewPdf(final boolean outside) {
+ public String viewFile(final boolean outside, final boolean pdf) {
final FacesContext facesContext = FacesContext.getCurrentInstance();
InputStream inputStream = null;
try {
- final String path = "content/30-concept/24-non-faces-response/x-sample.pdf";
+ final String path = "content/30-concept/24-non-faces-response/x-sample." + (pdf ? "pdf" : "txt");
inputStream = facesContext.getExternalContext().getResourceAsStream(path);
if (inputStream == null) {
inputStream = facesContext.getExternalContext().getResourceAsStream("/" + path);
}
final HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
- response.setContentType("application/pdf");
+ response.setContentType(pdf ? "application/pdf" : "text/plain");
if (outside) {
- response.setHeader("Content-Disposition", "attachment; filename=x-sample.pdf");
+ response.setHeader("Content-Disposition", "attachment; filename=x-sample." + (pdf ? "pdf" : "txt"));
}
IOUtils.copy(inputStream, response.getOutputStream());
} catch (final IOException e) {
- LOG.warn("Cannot deliver pdf", e);
+ LOG.warn("Cannot deliver " + (pdf ? "pdf" : "txt"), e);
return "error"; // response via faces
} finally {
IOUtils.closeQuietly(inputStream);
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/non-faces-response.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/non-faces-response.xhtml?rev=1780418&r1=1780417&r2=1780418&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/non-faces-response.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/non-faces-response.xhtml Thu Jan 26 16:15:06 2017
@@ -25,11 +25,17 @@
<tc:segmentLayout large="10;2">
- <tc:out value="A faces request to a non-faces-response. Inside of the Browser." id="o"/>
- <tc:button action="#{bestPracticeController.viewPdfInBrowser}" label="View PDF"/>
+ <tc:out value="A faces request to a non-faces-response. Inside of the Browser."/>
+ <tc:button action="#{bestPracticeController.viewFile(false, true)}" label="View PDF"/>
<tc:out value="A faces request to a non-faces-response. Outside of the Browser."/>
- <tc:button action="#{bestPracticeController.viewPdfOutsideOfBrowser}" label="View PDF" transition="false"/>
+ <tc:button action="#{bestPracticeController.viewFile(true, true)}" label="View PDF" transition="false"/>
+
+ <tc:out value="A faces request to a non-faces-response. Inside of the Browser."/>
+ <tc:button action="#{bestPracticeController.viewFile(false, false)}" label="View TXT"/>
+
+ <tc:out value="A faces request to a non-faces-response. Outside of the Browser."/>
+ <tc:button action="#{bestPracticeController.viewFile(true, false)}" label="View TXT" transition="true"/>
</tc:segmentLayout>
Problems:
@@ -41,8 +47,12 @@
<li>
BUG: Currently after a download the next AJAX is broken:
<tc:button label="test">
- <f:ajax render="o" execute="o"/>
+ <f:ajax render="millis"/>
</tc:button>
+
+ <tc:out label="Current SS:MMM" id="millis" value="#{partialReloadController.currentDate}">
+ <f:convertDateTime pattern="ss:SSS"/>
+ </tc:out>
</li>
</ul>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/x-sample.txt
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/x-sample.txt?rev=1780418&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/x-sample.txt (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/24-non-faces-response/x-sample.txt Thu Jan 26 16:15:06 2017
@@ -0,0 +1 @@
+Sample TXT