Author: vishwanathk
Date: Tue Aug 14 01:06:05 2012
New Revision: 1372693
URL: http://svn.apache.org/viewvc?rev=1372693&view=rev
Log:
Add example. CDI @Named @RequestScoped bean, used from JSF.
Added:
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/README.md
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/pom.xml
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/resources/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/META-INF/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/beans.xml
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/faces-config.xml
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/web.xml
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/calculator.xhtml
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/index.jsp
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/result.xhtml
Modified:
openejb/trunk/openejb/examples/ (props changed)
openejb/trunk/openejb/examples/pom.xml
Propchange: openejb/trunk/openejb/examples/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Aug 14 01:06:05 2012
@@ -8,3 +8,5 @@ target
.settings
out
+
+jsf
Added: openejb/trunk/openejb/examples/jsf-cdi-and-ejb/README.md
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/README.md?rev=1372693&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/jsf-cdi-and-ejb/README.md (added)
+++ openejb/trunk/openejb/examples/jsf-cdi-and-ejb/README.md Tue Aug 14
01:06:05 2012
@@ -0,0 +1,268 @@
+Title: JSF
+
+
+A simple web-app showing how to use dependency injection in JSF managed beans
using TomEE.
+
+It contains a Local Stateless session bean (CalculatorImpl) which adds two
numbers and returns the result.
+
+The application also contains a CDI managed bean (CalculatorBean), which uses
the EJB to add two numbers
+and display the results to the user. The EJB is injected in the managed bean
using @EJB annotation.
+
+You could run this in the latest Apache TomEE
[snapshot](https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/)
+
+The complete source code is below but lets break down to look at some smaller
snippets and see how it works.
+
+
+A little note on the setup:
+
+As for the libraries, myfaces-api and myfaces-impl are provided in tomee/lib
and hence they should not be a part of the
+war. In maven terms, they would be with scope 'provided'
+
+Also note that we use servlet 2.5 declaration in web.xml
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+And we use 2.0 version of faces-config
+
+ <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+To make this a cdi-aware-archive (i.e bean archive) an empty beans.xml is
added in WEB-INF
+
+ <?xml version="1.0" encoding="UTF-8"?>
+
+ <beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+ </beans>
+
+We'll first declare the FacesServlet in the web.xml
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+FacesServlet acts as the master controller.
+
+We'll then create the calculator.xhtml file.
+
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+
+Notice how we've used the bean here. By default, the bean name would be the
simple name of the bean
+class with the first letter in lower case.
+
+We've annotated the `CalculatorBean` with `@RequestScoped`.
+So when a request comes in, the bean is instantiated and placed in the request
scope.
+
+<h:inputText value='#{calculatorBean.x}'/>
+
+Here, getX() method of calculatorBean is invoked and the resulting value is
displayed.
+x being a Double, we rightly should see 0.0 displayed.
+
+When you change the value and submit the form, these entered values are bound
using the setters
+in the bean and then the commandButton-action method is invoked.
+
+In this case, CalculatorBean#add() is invoked.
+
+Calculator#add() delegates the work to the ejb, gets the result, stores it
+and then instructs what view is to be rendered.
+
+You're right. The return value "success" is checked up in faces-config
navigation-rules
+and the respective page is rendered.
+
+In our case, 'result.xhtml' page is rendered.
+
+The request scoped 'calculatorBean' is available here, and we use EL to
display the values.
+
+#Source Code
+
+## Calculator
+
+ package org.superbiz.jsf;
+
+ import javax.ejb.Remote;
+
+ @Remote
+ public interface Calculator {
+ public double add(double x, double y);
+ }
+
+## CalculatorBean
+
+ import javax.enterprise.context.RequestScoped;
+ import javax.inject.Named;
+
+ @RequestScoped
+ @Named
+ public class CalculatorBean {
+ @EJB
+ Calculator calculator;
+ private double x;
+ private double y;
+ private double result;
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getResult() {
+ return result;
+ }
+
+ public void setResult(double result) {
+ this.result = result;
+ }
+
+ public String add() {
+ result = calculator.add(x, y);
+ return "success";
+ }
+ }
+
+## CalculatorImpl
+
+ package org.superbiz.jsf;
+
+ import javax.ejb.Stateless;
+
+ @Stateless
+ public class CalculatorImpl implements Calculator {
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+ }
+
+
+#web.xml
+
+<?xml version="1.0"?>
+
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <description>MyProject web.xml</description>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
+
+
+#Calculator.xhtml
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+
+<h:body bgcolor="white">
+ <f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+</h:body>
+</html>
+
+
+ #Result.xhtml
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+<h:body>
+<f:view>
+ <h:form id="mainForm">
+ <h2><h:outputText value="Result of adding #{calculatorBean.x} and
#{calculatorBean.y} is #{calculatorBean.result }"/></h2>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+ </h:form>
+</f:view>
+</h:body>
+</html>
+
+ #faces-config.xml
+
+ <?xml version="1.0"?>
+ <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <navigation-rule>
+ <from-view-id>/calculator.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/result.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/result.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/calculator.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ </faces-config>
\ No newline at end of file
Added: openejb/trunk/openejb/examples/jsf-cdi-and-ejb/pom.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/pom.xml?rev=1372693&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/jsf-cdi-and-ejb/pom.xml (added)
+++ openejb/trunk/openejb/examples/jsf-cdi-and-ejb/pom.xml Tue Aug 14 01:06:05
2012
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz.jsf</groupId>
+ <artifactId>jsf-cdi-and-ejb</artifactId>
+ <packaging>war</packaging>
+ <name>OpenEJB :: Web Examples :: JSF - CDI and EJB</name>
+ <version>1.1-SNAPSHOT</version>
+ <url>http://openejb.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <finalName>jsf-cdi-and-ejb</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ <configuration>
+ <url>http://localhost:8080/manager/html
+ </url>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots/>
+ <id>apache-maven-snapshots</id>
+ <url>http://repository.apache.org/snapshots/
+ </url>
+ </repository>
+ <repository>
+ <id>java.net</id>
+ <url>http://download.java.net/maven/1</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>2.1.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <version>2.1.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.tomahawk</groupId>
+ <artifactId>tomahawk20</artifactId>
+ <version>1.1.13</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xmlParserAPIs</artifactId>
+ <groupId>xml-apis</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-4</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
\ No newline at end of file
Added:
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java?rev=1372693&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java
(added)
+++
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java
Tue Aug 14 01:06:05 2012
@@ -0,0 +1,25 @@
+/**
+ *
+ * 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.
+ */
+package org.superbiz.jsf;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface Calculator {
+ public double add(double x, double y);
+}
Added:
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java?rev=1372693&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
(added)
+++
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
Tue Aug 14 01:06:05 2012
@@ -0,0 +1,62 @@
+/*
+ * 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.
+*/
+package org.superbiz.jsf;
+
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+@RequestScoped
+@Named
+public class CalculatorBean {
+ @EJB
+ Calculator calculator;
+ private double x;
+ private double y;
+ private double result;
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getResult() {
+ return result;
+ }
+
+ public void setResult(double result) {
+ this.result = result;
+ }
+
+ public String add() {
+ result = calculator.add(x, y);
+ return "success";
+ }
+}
\ No newline at end of file
Added:
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java?rev=1372693&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java
(added)
+++
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java
Tue Aug 14 01:06:05 2012
@@ -0,0 +1,30 @@
+/**
+ *
+ * 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.
+ */
+package org.superbiz.jsf;
+
+import javax.ejb.Stateless;
+
+
+@Stateless
+public class CalculatorImpl implements Calculator {
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+
+}
Added:
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/beans.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/beans.xml?rev=1372693&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/beans.xml
(added)
+++
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/beans.xml
Tue Aug 14 01:06:05 2012
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+</beans>
\ No newline at end of file
Added:
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/faces-config.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/faces-config.xml?rev=1372693&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/faces-config.xml
(added)
+++
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/faces-config.xml
Tue Aug 14 01:06:05 2012
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+ * 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.
+-->
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <navigation-rule>
+ <from-view-id>/calculator.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/result.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/result.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/calculator.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+</faces-config>
\ No newline at end of file
Added:
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/web.xml?rev=1372693&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/web.xml
(added)
+++
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/web.xml
Tue Aug 14 01:06:05 2012
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+
+<!--
+ * 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.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <description>MyProject web.xml</description>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
Added:
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/calculator.xhtml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/calculator.xhtml?rev=1372693&view=auto
==============================================================================
---
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/calculator.xhtml
(added)
+++
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/calculator.xhtml
Tue Aug 14 01:06:05 2012
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* 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.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+
+<h:body bgcolor="white">
+ <f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+</h:body>
+</html>
Added: openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/index.jsp
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/index.jsp?rev=1372693&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/index.jsp
(added)
+++ openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/index.jsp
Tue Aug 14 01:06:05 2012
@@ -0,0 +1,22 @@
+<!--
+* 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.
+-->
+<%@ page session="false" %>
+<%
+ response.sendRedirect("calculator.jsf");
+%>
\ No newline at end of file
Added:
openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/result.xhtml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/result.xhtml?rev=1372693&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/result.xhtml
(added)
+++ openejb/trunk/openejb/examples/jsf-cdi-and-ejb/src/main/webapp/result.xhtml
Tue Aug 14 01:06:05 2012
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* 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.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+<h:body>
+<f:view>
+ <h:form id="mainForm">
+ <h2>Result of adding #{calculatorBean.x} and #{calculatorBean.y} is
#{calculatorBean.result }</h2>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+ </h:form>
+</f:view>
+</h:body>
+</html>
\ No newline at end of file
Modified: openejb/trunk/openejb/examples/pom.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/pom.xml?rev=1372693&r1=1372692&r2=1372693&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/pom.xml (original)
+++ openejb/trunk/openejb/examples/pom.xml Tue Aug 14 01:06:05 2012
@@ -78,6 +78,7 @@
<module>jpa-hibernate</module>
<module>jpa-enumerated</module>
<module>jsf-managedBean-and-ejb</module>
+ <module>jsf-cdi-and-ejb</module>
<module>lookup-of-ejbs</module>
<module>lookup-of-ejbs-with-descriptor</module>
<module>mbean-auto-registration</module>