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 2006/01/17 22:34:40 UTC
svn commit: r369925 - in /incubator/tobago/trunk/tobago-example: ./
tobago-example-nonfacesrequest/
tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/foreach/
tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/...
Author: lofwyr
Date: Tue Jan 17 13:34:26 2006
New Revision: 369925
URL: http://svn.apache.org/viewcvs?rev=369925&view=rev
Log:
sample to show the use of NonFacesRequestServlet
Added:
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/
- copied from r369857, incubator/tobago/trunk/tobago-example/tobago-example-foreach/
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishPond.java
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishServlet.java
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/pond.jsp
Removed:
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/foreach/BirdList.java
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/foreach.jsp
Modified:
incubator/tobago/trunk/tobago-example/pom.xml
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/pom.xml
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/classes/log4j.xml
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/faces-config.xml
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/tobago-config.xml
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/web.xml
incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/index.jsp
Modified: incubator/tobago/trunk/tobago-example/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/pom.xml?rev=369925&r1=369924&r2=369925&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/pom.xml (original)
+++ incubator/tobago/trunk/tobago-example/pom.xml Tue Jan 17 13:34:26 2006
@@ -15,5 +15,6 @@
<module>tobago-example-blank</module>
<module>tobago-example-demo</module>
<module>tobago-example-foreach</module>
+ <module>tobago-example-nonfacesrequest</module>
</modules>
</project>
Modified: incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/pom.xml?rev=369925&r1=369857&r2=369925&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/pom.xml (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/pom.xml Tue Jan 17 13:34:26 2006
@@ -24,11 +24,11 @@
<artifactId>tobago-example</artifactId>
<version>1.0.7-SNAPSHOT</version>
</parent>
- <artifactId>tobago-example-foreach</artifactId>
+ <artifactId>tobago-example-nonfacesrequest</artifactId>
<packaging>war</packaging>
- <name>Tobago Example Foreach</name>
+ <name>Tobago Example Non-Faces-Request</name>
<build>
- <finalName>tobago-example-foreach</finalName>
+ <finalName>tobago-example-nonfacesrequest</finalName>
<plugins>
<plugin>
<groupId>org.apache.myfaces.tobago</groupId>
@@ -65,13 +65,6 @@
<dependency>
<groupId>org.apache.myfaces.tobago</groupId>
<artifactId>tobago-theme-speyside</artifactId>
- <version>${version}</version>
- <classifier>THEME</classifier>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.myfaces.tobago</groupId>
- <artifactId>tobago-theme-richmond</artifactId>
<version>${version}</version>
<classifier>THEME</classifier>
<scope>provided</scope>
Added: incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishPond.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishPond.java?rev=369925&view=auto
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishPond.java (added)
+++ incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishPond.java Tue Jan 17 13:34:26 2006
@@ -0,0 +1,50 @@
+package org.apache.myfaces.tobago.example.nonfacesrequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Random;
+
+public class FishPond {
+
+ private Log LOG = LogFactory.getLog(FishPond.class);
+
+ private Map<String, String> fishes;
+
+ private String selectedFish;
+
+ public FishPond() {
+ fishes = new HashMap<String, String>();
+ fishes.put("0", "Scholle");
+ fishes.put("1", "Hai");
+ fishes.put("2", "Luce");
+ fishes.put("3", "Halibut");
+ fishes.put("4", "Tamboril");
+ }
+
+ public String random() {
+ Random random = new Random(System.currentTimeMillis());
+
+ selectedFish = fishes.get("" + random.nextInt(fishes.size()));
+
+ LOG.info("select via random: '" + selectedFish + "'");
+
+ return "view";
+ }
+
+ public String select(String id) {
+ selectedFish = fishes.get(id);
+
+ LOG.info("select via id: '" + selectedFish + "'");
+
+ return "view";
+ }
+
+ public String getSelectedFish() {
+ return selectedFish;
+ }
+
+
+}
Added: incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishServlet.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishServlet.java?rev=369925&view=auto
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishServlet.java (added)
+++ incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/java/org/apache/myfaces/tobago/example/nonfacesrequest/FishServlet.java Tue Jan 17 13:34:26 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2002-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.myfaces.tobago.example.nonfacesrequest;
+
+import org.apache.myfaces.tobago.servlet.NonFacesRequestServlet;
+import org.apache.myfaces.tobago.util.VariableResolverUtil;
+import org.apache.myfaces.tobago.example.nonfacesrequest.FishPond;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+
+public class FishServlet extends NonFacesRequestServlet {
+
+ private Log LOG = LogFactory.getLog(FishServlet.class);
+
+ public String invokeApplication(FacesContext facesContext) {
+
+ String id = (String) facesContext.getExternalContext().getRequestParameterMap().get("id");
+ LOG.info("id='" + id + "'");
+
+ FishPond fishPond = (FishPond) VariableResolverUtil.resolveVariable(facesContext, "fishPond");
+
+ String outcome = fishPond.select(id);
+
+ return outcome;
+ }
+}
Modified: incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/classes/log4j.xml
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/classes/log4j.xml?rev=369925&r1=369857&r2=369925&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/classes/log4j.xml (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/classes/log4j.xml Tue Jan 17 13:34:26 2006
@@ -21,7 +21,7 @@
<log4j:configuration>
<appender name="logfile" class="org.apache.log4j.FileAppender">
- <param name="File" value="tobago-example-foreach.log" />
+ <param name="File" value="tobago-example-nonfacesrequest.log" />
<param name="Append" value="true" />
<param name="Encoding" value="UTF-8" />
<layout class="org.apache.log4j.PatternLayout">
Modified: incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/faces-config.xml?rev=369925&r1=369857&r2=369925&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/faces-config.xml Tue Jan 17 13:34:26 2006
@@ -25,21 +25,19 @@
<application>
<locale-config>
<default-locale>en</default-locale>
- <supported-locale>en_US</supported-locale>
- <supported-locale>en_GB</supported-locale>
- <supported-locale>de</supported-locale>
- <supported-locale>de_DE</supported-locale>
- <supported-locale>de_AT</supported-locale>
- <supported-locale>de_CH</supported-locale>
- <supported-locale>ja_JP</supported-locale>
- <supported-locale>ru_RU</supported-locale>
</locale-config>
</application>
<managed-bean>
- <managed-bean-name>birdList</managed-bean-name>
- <managed-bean-class>org.apache.myfaces.tobago.example.foreach.BirdList</managed-bean-class>
+ <managed-bean-name>fishPond</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.tobago.example.nonfacesrequest.FishPond</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+
+ <navigation-rule>
+ <navigation-case>
+ <to-view-id>/pond.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
</faces-config>
Modified: incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/tobago-config.xml
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/tobago-config.xml?rev=369925&r1=369857&r2=369925&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/tobago-config.xml (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/tobago-config.xml Tue Jan 17 13:34:26 2006
@@ -24,7 +24,6 @@
<theme-config>
<default-theme>org.apache.myfaces.tobago.context.SpeysideTheme</default-theme>
<supported-theme>org.apache.myfaces.tobago.context.ScarboroughTheme</supported-theme>
- <supported-theme>org.apache.myfaces.tobago.context.RichmondTheme</supported-theme>
</theme-config>
<resource-dir>tobago-resource</resource-dir>
Modified: incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/web.xml?rev=369925&r1=369857&r2=369925&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/WEB-INF/web.xml Tue Jan 17 13:34:26 2006
@@ -16,28 +16,19 @@
* limitations under the License.
-->
-
-
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
- <display-name>Tobago Demo Application</display-name>
-
- <filter>
- <filter-name>multipartFormdataFilter</filter-name>
- <filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>multipartFormdataFilter</filter-name>
- <url-pattern>/faces/*</url-pattern>
- </filter-mapping>
+ <display-name>Tobago Demo Non-Faces-Request</display-name>
<!-- workaround (e.g. for Oracle AS 10.1.2.0.0)-->
+<!--
<listener>
<listener-class>org.apache.myfaces.tobago.webapp.TobagoServletContextListener</listener-class>
</listener>
+-->
<!-- servlet -->
<!-- no longer needed since Weblogic 8.1 SP 3
@@ -55,9 +46,9 @@
</servlet>
<servlet>
- <servlet-name>TemplateServlet</servlet-name>
- <servlet-class>org.apache.myfaces.tobago.servlet.TemplateServlet</servlet-class>
- <load-on-startup>2</load-on-startup>
+ <servlet-name>FishServlet</servlet-name>
+ <servlet-class>org.apache.myfaces.tobago.example.nonfacesrequest.FishServlet</servlet-class>
+ <load-on-startup>3</load-on-startup>
</servlet>
<!-- servlet-mapping -->
@@ -68,28 +59,16 @@
</servlet-mapping>
<servlet-mapping>
- <servlet-name>TemplateServlet</servlet-name>
- <url-pattern>*.view</url-pattern>
+ <servlet-name>FishServlet</servlet-name>
+ <!--for sun ri (tested with version 1.1.01)-->
+ <!--<url-pattern>/FishServlet</url-pattern>-->
+ <!--for myfaces (tested with version 1.1.1)-->
+ <url-pattern>/faces/FishServlet</url-pattern>
</servlet-mapping>
- <!-- mime -->
- <mime-mapping>
- <extension>wml</extension>
- <mime-type>text/vnd.wap.wml</mime-type>
- </mime-mapping>
- <mime-mapping>
- <extension>wbmp</extension>
- <mime-type>image/vnd.wap.wbmp</mime-type>
- </mime-mapping>
-
<!-- The Usual Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
-
- <error-page>
- <exception-type>java.lang.Throwable</exception-type>
- <location>/errorPage.jsp</location>
- </error-page>
</web-app>
Modified: incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/index.jsp?rev=369925&r1=369857&r2=369925&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/index.jsp (original)
+++ incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/index.jsp Tue Jan 17 13:34:26 2006
@@ -13,4 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
--%>
-<jsp:forward page="faces/foreach.jsp" />;
+<html>
+<body>
+<a href="faces/FishServlet?id=0">faces/FishServlet?id=0</a><br/>
+<a href="faces/FishServlet?id=1">faces/FishServlet?id=1</a><br/>
+<a href="faces/FishServlet?id=2">faces/FishServlet?id=2</a><br/>
+<a href="faces/FishServlet?id=3">faces/FishServlet?id=3</a><br/>
+<a href="faces/FishServlet?id=4">faces/FishServlet?id=4</a><br/>
+</body>
+</html>
Added: incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/pond.jsp
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/pond.jsp?rev=369925&view=auto
==============================================================================
--- incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/pond.jsp (added)
+++ incubator/tobago/trunk/tobago-example/tobago-example-nonfacesrequest/src/main/webapp/pond.jsp Tue Jan 17 13:34:26 2006
@@ -0,0 +1,13 @@
+<%@ 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" %>
+<f:view>
+ <tc:page>
+ <f:facet name="layout">
+ <tc:gridLayout columns="100px;30px" margin="20px" />
+ </f:facet>
+
+ <tx:in label="Selected:" value="#{fishPond.selectedFish}" readonly="true" />
+ <tc:button label="random" action="#{fishPond.random}" />
+ </tc:page>
+</f:view>