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 2007/02/12 17:07:12 UTC
svn commit: r506516 - in /myfaces/tobago/trunk/example/demo/src/main:
java/org/apache/myfaces/tobago/example/demo/
java/org/apache/myfaces/tobago/example/demo/bestpractice/ webapp/WEB-INF/
webapp/best-practice/ webapp/overview/ webapp/tobago-resource/h...
Author: lofwyr
Date: Mon Feb 12 08:07:11 2007
New Revision: 506516
URL: http://svn.apache.org/viewvc?view=rev&rev=506516
Log:
demo of Non Faces Response: TOBAGO-281
Added:
myfaces/tobago/trunk/example/demo/src/main/webapp/best-practice/non-faces-response.jsp
myfaces/tobago/trunk/example/demo/src/main/webapp/best-practice/sample.pdf (with props)
Modified:
myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java
myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java
myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml
myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheet.jsp
myfaces/tobago/trunk/example/demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml
Modified: myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java?view=diff&rev=506516&r1=506515&r2=506516
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java (original)
+++ myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java Mon Feb 12 08:07:11 2007
@@ -69,6 +69,7 @@
bestPractice.add(new DefaultMutableTreeNode(new Node("error", "best-practice/error")));
bestPractice.add(new DefaultMutableTreeNode(new Node("theme", "best-practice/theme")));
bestPractice.add(new DefaultMutableTreeNode(new Node("transition", "best-practice/transition")));
+ bestPractice.add(new DefaultMutableTreeNode(new Node("nonFacesResponse", "best-practice/non-faces-response")));
tree.add(bestPractice);
state = new TreeState();
Modified: myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java?view=diff&rev=506516&r1=506515&r2=506516
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java (original)
+++ myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/bestpractice/BestPracticeController.java Mon Feb 12 08:07:11 2007
@@ -1,5 +1,14 @@
package org.apache.myfaces.tobago.example.demo.bestpractice;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.io.IOException;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,7 +28,40 @@
public class BestPracticeController {
+ private static final Log LOG = LogFactory.getLog(BestPracticeController.class);
+
public String throwException() {
throw new RuntimeException("This exception is forced by the user.");
+ }
+
+ public String viewPdfInBrowser() {
+ return viewPdf(false);
+ }
+
+ public String viewPdfOutsideOfBrowser() {
+ return viewPdf(true);
+ }
+
+ private String viewPdf(boolean outside) {
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ InputStream inputStream = null;
+ try {
+ inputStream = facesContext.getExternalContext().getResourceAsStream("best-practice/sample.pdf");
+ HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
+ response.setContentType("application/pdf");
+ if (outside) {
+ response.setHeader("Content-Disposition", "attachment; filename=sample.pdf");
+ }
+ IOUtils.copy(inputStream, response.getOutputStream());
+ } catch (IOException e) {
+ LOG.warn("Cannot deliver pdf", e);
+ return "error"; // response via faces
+ } finally {
+ IOUtils.closeQuietly(inputStream);
+ }
+ facesContext.responseComplete();
+ return null;
}
}
Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml?view=diff&rev=506516&r1=506515&r2=506516
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml Mon Feb 12 08:07:11 2007
@@ -206,6 +206,10 @@
<from-outcome>best-practice/transition-after-sleep</from-outcome>
<to-view-id>/best-practice/transition-after-sleep.jsp</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>best-practice/non-faces-response</from-outcome>
+ <to-view-id>/best-practice/non-faces-response.jsp</to-view-id>
+ </navigation-case>
</navigation-rule>
<navigation-rule>
Added: myfaces/tobago/trunk/example/demo/src/main/webapp/best-practice/non-faces-response.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/best-practice/non-faces-response.jsp?view=auto&rev=506516
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/best-practice/non-faces-response.jsp (added)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/best-practice/non-faces-response.jsp Mon Feb 12 08:07:11 2007
@@ -0,0 +1,37 @@
+<%--
+ * 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.
+--%>
+<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %>
+
+<layout:overview>
+ <jsp:body>
+ <tc:box label="Non Faces Response (e. g. a download link)">
+ <f:facet name="layout">
+ <tc:gridLayout rows="35px;35px;*" columns="*;100px" />
+ </f:facet>
+
+ <tc:out value="A faces request to a non-faces-response. Inside of the Browser." />
+ <tc:button action="#{bestPracticeController.viewPdfInBrowser}" 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:cell />
+ <tc:cell />
+
+ </tc:box>
+ </jsp:body>
+</layout:overview>
Added: myfaces/tobago/trunk/example/demo/src/main/webapp/best-practice/sample.pdf
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/best-practice/sample.pdf?view=auto&rev=506516
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/example/demo/src/main/webapp/best-practice/sample.pdf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheet.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheet.jsp?view=diff&rev=506516&r1=506515&r2=506516
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheet.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/overview/sheet.jsp Mon Feb 12 08:07:11 2007
@@ -13,13 +13,13 @@
* 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.
---%><%@
- taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %><%@
- taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %><%@
- taglib uri="http://java.sun.com/jsf/core" prefix="f" %><%@
- taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %><%@
- page pageEncoding="UTF-8"
- %><layout:overview>
+--%>
+<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
+<%@ taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %>
+<%@ page pageEncoding="UTF-8" %>
+<layout:overview>
<jsp:body>
<tc:panel>
<f:facet name="layout">
@@ -113,8 +113,8 @@
</tc:toolBar>
</f:facet>
- <tc:sheet value="#{demo.solarList}" id="sheet"
- columns="3*;1*;3*;3*;3*;3*" var="luminary"
+ <tc:sheet value="#{demo.solarList}" id="sheet"
+ columns="300px;100px;300px;300px;300px;300px" var="luminary"
state="#{demo.sheetState}"
showHeader="#{overviewController.sheetConfig.sheetShowHeader}"
showRowRange="#{overviewController.sheetConfig.sheetRowPagingPosition}"
Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml?view=diff&rev=506516&r1=506515&r2=506516
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml Mon Feb 12 08:07:11 2007
@@ -55,6 +55,7 @@
<entry key="error">Error Handling</entry>
<entry key="theme">Themes</entry>
<entry key="transition">Transition</entry>
+ <entry key="nonFacesResponse">Non Faces Resp.</entry>
<entry key="submit">Submit</entry>
<entry key="cancel">Cancel</entry>