diff --git a/Calculator-Bean/.classpath b/Calculator-Bean/.classpath index 218b82a1b13523377ff96bd96a18fda214c784df..98ce604bf84261ffca557093d5aef41c1f3b7d31 100644 --- a/Calculator-Bean/.classpath +++ b/Calculator-Bean/.classpath @@ -12,5 +12,6 @@ </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> + <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="output" path="build/classes"/> </classpath> diff --git a/Calculator-Web/WebContent/WEB-INF/.faces-config.xml.jsfdia b/Calculator-Web/WebContent/WEB-INF/.faces-config.xml.jsfdia new file mode 100644 index 0000000000000000000000000000000000000000..3d873e541e8c522bdd868dfdfa060e8cc51f10c0 --- /dev/null +++ b/Calculator-Web/WebContent/WEB-INF/.faces-config.xml.jsfdia @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<PROCESS model-entity="JSFProcess"> + <PROCESS-ITEM NAME="rules:#formulario.xhtml" PATH="/formulario.xhtml" + SHAPE="259,164,0,0" model-entity="JSFProcessGroup"> + <PROCESS-ITEM ID="rules:#formulario.xhtml:0" NAME="item" + PATH="/formulario.xhtml" model-entity="JSFProcessItem"> + <PROCESS-ITEM-OUTPUT ID="Soma::#resultado.xhtml" NAME="output" + PATH="/resultado.xhtml" TARGET="rules:#resultado.xhtml" TITLE="Soma" model-entity="JSFProcessItemOutput"/> + </PROCESS-ITEM> + </PROCESS-ITEM> + <PROCESS-ITEM NAME="rules:#resultado.xhtml" PATH="/resultado.xhtml" + SHAPE="272,360,50,25" model-entity="JSFProcessGroup" persistent="true"/> +</PROCESS> diff --git a/Calculator-Web/WebContent/WEB-INF/faces-config.xml b/Calculator-Web/WebContent/WEB-INF/faces-config.xml index cd6bf62db53561abd215f0ccfdf4037a53d0313f..74bb67c69443f9e6c13bce3b28bd78eda5d16f72 100644 --- a/Calculator-Web/WebContent/WEB-INF/faces-config.xml +++ b/Calculator-Web/WebContent/WEB-INF/faces-config.xml @@ -1,6 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> - <faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"> - -</faces-config> \ No newline at end of file + <managed-bean> + <managed-bean-name>calculatorManagedBean</managed-bean-name> + <managed-bean-class>br.ufrn.imd.imd0409.calculator.view.CalculatorManagedBean</managed-bean-class> + <managed-bean-scope>request</managed-bean-scope> + </managed-bean> + <navigation-rule> + <from-view-id>/formulario.xhtml</from-view-id> + <navigation-case> + <from-outcome>Soma</from-outcome> + <to-view-id>/resultado.xhtml</to-view-id> + </navigation-case> + </navigation-rule> + <application/> +</faces-config> diff --git a/Calculator-Web/WebContent/formulario.xhtml b/Calculator-Web/WebContent/formulario.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..347cfb1e92d03891d9ab4e22de32d2fbb007a445 --- /dev/null +++ b/Calculator-Web/WebContent/formulario.xhtml @@ -0,0 +1,19 @@ +<!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:ui="http://java.sun.com/jsf/facelets" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:h="http://java.sun.com/jsf/html"> + +<h:head>Testing Calculator Bean from JSF</h:head> +<body> + <h:form> + <h:panelGrid border="1" columns="2"> + <h:outputText value="Primeiro numero"></h:outputText> + <h:inputText value="#{calculatorManagedBean.numero1}" /> + <h:outputText value="Segundo numero"></h:outputText> + <h:inputText value="#{calculatorManagedBean.numero2}"/> + </h:panelGrid> + <h:commandButton value="Soma" action="#{calculatorManagedBean.calcula}"/> + </h:form> +</body> +</html> diff --git a/Calculator-Web/WebContent/index.html b/Calculator-Web/WebContent/index.html new file mode 100644 index 0000000000000000000000000000000000000000..cdb9323af6a31456a6f6e200a6b5f019352939ed --- /dev/null +++ b/Calculator-Web/WebContent/index.html @@ -0,0 +1,12 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="UTF-8"> +<title>My First EJB</title> +</head> +<body> +<a href="faces/formulario.xhtml">Exemplo com JSF</a><br> +<a href="formulario.html">Exemplo com Servlet</a> + +</body> +</html> \ No newline at end of file diff --git a/Calculator-Web/WebContent/resultado.xhtml b/Calculator-Web/WebContent/resultado.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..f644069b10724bcbe8e15b2ebacf7974e1a3b320 --- /dev/null +++ b/Calculator-Web/WebContent/resultado.xhtml @@ -0,0 +1,18 @@ +<!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:ui="http://java.sun.com/jsf/facelets" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:h="http://java.sun.com/jsf/html"> + +<h:head>O resultado</h:head> +<body> + <h:panelGrid border="1" columns="2"> + <h:outputLabel value="Numero 1"/> + <h:outputText value="#{calculatorManagedBean.numero1}"/> + <h:outputLabel value="Numero 2"/> + <h:outputText value="#{calculatorManagedBean.numero2}"/> + <h:outputLabel value="Resultado"></h:outputLabel> + <h:outputText value="#{calculatorManagedBean.resultado}"/> + </h:panelGrid> +</body> +</html> diff --git a/README.md b/README.md index 0ba8a1dfe4a756a9926ca4ca68e0313926f10701..b2ce40fdabe9ff1ccc41c01229218073ab697d46 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ # MyFirstEJB-Calculator + +Implementation of the Calculator Bean example from the Book +Enterprise JavaBeans 3.1, 6th Edition +By Andrew Lee Rubinger, Bill Burke