Modified: websites/staging/tomee/trunk/content/master/examples/jsf-cdi-and-ejb.html ============================================================================== --- websites/staging/tomee/trunk/content/master/examples/jsf-cdi-and-ejb.html (original) +++ websites/staging/tomee/trunk/content/master/examples/jsf-cdi-and-ejb.html Sat Sep 7 14:30:44 2019 @@ -95,49 +95,119 @@ <div class="row"> <div class="col-md-12"> - <p>The simple application contains a CDI managed bean <code>CalculatorBean</code>, which uses the <code>Calculator</code> EJB to add two numbers and display the results to the user. The EJB is injected in the managed bean using @Inject annotation.</p> -<p>You could run this in the latest Apache TomEE <a href="https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/">snapshot</a></p> -<p>The complete source code is below but lets break down to look at some smaller snippets and see how it works.</p> + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> +<p>The simple application contains a CDI managed bean <code>CalculatorBean</code>, +which uses the <code>Calculator</code> EJB to add two numbers and display the +results to the user. The EJB is injected in the managed bean using +@Inject annotation.</p> +</div> +<div class="paragraph"> +<p>You could run this in the latest Apache TomEE +<a href="https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/">snapshot</a></p> +</div> +<div class="paragraph"> +<p>The complete source code is below but lets break down to look at some +smaller snippets and see how it works.</p> +</div> +<div class="paragraph"> <p>A little note on the setup:</p> -<p>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'</p> -<p>Also note that we use servlet 2.5 declaration in web.xml<br/><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br/> xmlns="http://java.sun.com/xml/ns/javaee"<br/> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"<br/> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br/> <a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd</a>"<br/> version="2.5"></p> +</div> +<div class="paragraph"> +<p>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'</p> +</div> +<div class="paragraph"> +<p>Also note that we use servlet 2.5 declaration in web.xml</p> +</div> +<div class="paragraph"> <p>And we use 2.0 version of faces-config</p> -<p><faces-config xmlns="http://java.sun.com/xml/ns/javaee"<br/> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br/> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br/> <a href="http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd</a>"<br/> version="2.0"></p> -<p>To make this a cdi-aware-archive (i.e bean archive) an empty beans.xml is added in WEB-INF</p> -<pre><code> <?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> -</code></pre> -<p>We'll first declare the FacesServlet in the web.xml</p> -<pre><code> <servlet> +</div> +<div class="paragraph"> +<p>To make this a cdi-aware-archive (i.e bean archive) an empty beans.xml +is added in WEB-INF</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> <?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></pre> +</div> +</div> +<div class="paragraph"> +<p>Weâll first declare the FacesServlet in the web.xml</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> - </servlet> -</code></pre> + </servlet></pre> +</div> +</div> +<div class="paragraph"> <p>FacesServlet acts as the master controller.</p> -<p>We'll then create the calculator.xhtml file.</p> -<pre><code> <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"/> -</code></pre> -<p>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.</p> -<p>We've annotated the <code>CalculatorBean</code> with <code>@RequestScoped</code>. So when a request comes in, the bean is instantiated and placed in the request scope.</p> -<p><h:inputText value='#{calculatorBean.x}'/></p> -<p>Here, getX() method of calculatorBean is invoked and the resulting value is displayed. x being a Double, we rightly should see 0.0 displayed.</p> -<p>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.</p> +</div> +<div class="paragraph"> +<p>Weâll then create the calculator.xhtml file.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> <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"/></pre> +</div> +</div> +<div class="paragraph"> +<p>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.</p> +</div> +<div class="paragraph"> +<p>Weâve annotated the <code>CalculatorBean</code> with <code>@RequestScoped</code>. So when a +request comes in, the bean is instantiated and placed in the request +scope.</p> +</div> +<div class="paragraph"> +<p>Here, getX() method of calculatorBean is invoked and the resulting value +is displayed. x being a Double, we rightly should see 0.0 displayed.</p> +</div> +<div class="paragraph"> +<p>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.</p> +</div> +<div class="paragraph"> <p>In this case, CalculatorBean#add() is invoked.</p> -<p>Calculator#add() delegates the work to the ejb, gets the result, stores it and then returns what view is to be rendered.</p> -<p>The return value "success" is checked up in faces-config navigation-rules and the respective page is rendered.</p> -<p>In our case, 'result.xhtml' page is rendered where use EL and display the result from the request-scoped <code>calculatorBean</code>.</p> -<h1>Source Code</h1> -<h2>CalculatorBean</h2> -<pre><code>import javax.enterprise.context.RequestScoped; +</div> +<div class="paragraph"> +<p>Calculator#add() delegates the work to the ejb, gets the result, stores +it and then returns what view is to be rendered.</p> +</div> +<div class="paragraph"> +<p>The return value <code>success</code> is checked up in faces-config +navigation-rules and the respective page is rendered.</p> +</div> +<div class="paragraph"> +<p>In our case, <code>result.xhtml</code> page is rendered where use EL and display +the result from the request-scoped <code>calculatorBean</code>.</p> +</div> +</div> +</div> +<h1 id="_source_code" class="sect0">Source Code</h1> +<div class="sect1"> +<h2 id="_calculatorbean">CalculatorBean</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>import javax.enterprise.context.RequestScoped; import javax.inject.Named; import javax.inject.Inject; @@ -176,12 +246,19 @@ public class CalculatorBean { public String add() { result = calculator.add(x, y); - return "success"; + return "success"; } -} -</code></pre> -<h2>Calculator</h2> -<pre><code>package org.superbiz.jsf; +}</pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_calculator">Calculator</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>package org.superbiz.jsf; import javax.ejb.Stateless; @@ -191,26 +268,57 @@ public class Calculator{ public double add(double x, double y) { return x + y; } -} -</code></pre> -<h1>web.xml</h1> -<p><?xml version="1.0"?></p> -<p><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br/> xmlns="http://java.sun.com/xml/ns/javaee"<br/> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"<br/> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br/> <a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd</a>"<br/> version="2.5"></p> -<p><description>MyProject web.xml</description></p> -<p><!-- Faces Servlet --><br/> <servlet><br/> <servlet-name>Faces Servlet</servlet-name><br/> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class><br/> <load-on-startup>1</load-on-startup><br/> </servlet></p> -<p><!-- Faces Servlet Mapping --><br/> <servlet-mapping><br/> <servlet-name>Faces Servlet</servlet-name><br/> <url-pattern>*.jsf</url-pattern><br/> </servlet-mapping></p> -<p><!-- Welcome files --><br/> <welcome-file-list><br/> <welcome-file>index.jsp</welcome-file><br/> <welcome-file>index.html</welcome-file><br/> </welcome-file-list></p> -<p></web-app></p> -<h1>Calculator.xhtml</h1> -<p><?xml version="1.0" encoding="UTF-8"?><br/><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br/>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br/><html xmlns="http://www.w3.org/1999/xhtml"<br/> xmlns:f="http://java.sun.com/jsf/core"<br/> xmlns:h="http://java.sun.com/jsf/html"></p> -<p><h:body bgcolor="white"><br/> <f:view><br/> <h:form><br/> <h:panelGrid columns="2"><br/> <h:outputText value='Enter first number'/><br/> <h:inputText value='#{calculatorBean.x}'/><br/> <h:outputText value='Enter second number'/><br/> <h:inputText value='#{calculatorBean.y}'/><br/> <h:commandButton action="#{calculatorBean.add}" value="Add"/><br/> </h:panelGrid><br/> </h:form><br/> </f:view><br/></h:body><br/></html></p> +}</pre> +</div> +</div> +<div class="paragraph"> +<p>#web.xml</p> +</div> +<div class="paragraph"> +<p>MyProject web.xml</p> +</div> +<div class="paragraph"> +<p>Faces Servlet javax.faces.webapp.FacesServlet 1</p> +</div> +<div class="paragraph"> +<p>Faces Servlet *.jsf</p> +</div> +<div class="paragraph"> +<p>index.jsp index.html</p> +</div> +<div class="paragraph"> +<p>#Calculator.xhtml</p> +</div> +<div class="paragraph"> +<p><!DOCTYPE html PUBLIC <code>-//W3C//DTD XHTML 1.0 Transitional//EN'' +</code><a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''>" class="bare">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''></a>;</p> +</div> +<div class="paragraph"> <p>#Result.xhtml</p> -<p><?xml version="1.0" encoding="UTF-8"?><br/><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br/> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br/><html xmlns="http://www.w3.org/1999/xhtml"<br/> xmlns:f="http://java.sun.com/jsf/core"<br/> xmlns:h="http://java.sun.com/jsf/html"></p> -<p><h:body><br/><f:view><br/> <h:form id="mainForm"><br/> <h2><h:outputText value="Result of adding #{calculatorBean.x} and #{calculatorBean.y} is #{calculatorBean.result }"/></h2><br/> <h:commandLink action="back"><br/> <h:outputText value="Home"/><br/> </h:commandLink><br/> </h:form><br/></f:view><br/></h:body><br/></html></p> +</div> +<div class="paragraph"> +<p><!DOCTYPE html PUBLIC <code>-//W3C//DTD XHTML 1.0 Transitional//EN'' +</code><a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''>" class="bare">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''></a>;</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> <h:commandLink action="back"> + <h:outputText value="Home"/> + </h:commandLink> +</h:form></pre> +</div> +</div> +<div class="paragraph"> <p>#faces-config.xml</p> -<p><?xml version="1.0"?><br/> <faces-config xmlns="http://java.sun.com/xml/ns/javaee"<br/> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br/> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br/> <a href="http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd</a>"<br/> version="2.0"></p> -<p><navigation-rule><br/> <from-view-id>/calculator.xhtml</from-view-id><br/> <navigation-case><br/> <from-outcome>success</from-outcome><br/> <to-view-id>/result.xhtml</to-view-id><br/> </navigation-case><br/> </navigation-rule></p> -<p><navigation-rule><br/> <from-view-id>/result.xhtml</from-view-id><br/> <navigation-case><br/> <from-outcome>back</from-outcome><br/> <to-view-id>/calculator.xhtml</to-view-id><br/> </navigation-case><br/> </navigation-rule><br/> </faces-config></p> +</div> +<div class="paragraph"> +<p>/calculator.xhtml success /result.xhtml</p> +</div> +<div class="paragraph"> +<p>/result.xhtml back /calculator.xhtml</p> +</div> +</div> +</div> </div> </div>
Modified: websites/staging/tomee/trunk/content/master/examples/mp-jwt-bean-validation-strongly-typed.html ============================================================================== --- websites/staging/tomee/trunk/content/master/examples/mp-jwt-bean-validation-strongly-typed.html (original) +++ websites/staging/tomee/trunk/content/master/examples/mp-jwt-bean-validation-strongly-typed.html Sat Sep 7 14:30:44 2019 @@ -98,6 +98,18 @@ <div class="paragraph"> <p>TODO</p> </div> +<div class="admonitionblock caution"> +<table> +<tr> +<td class="icon"> +<i class="fa icon-caution" title="Caution"></i> +</td> +<td class="content"> +This feature has been temporarily removed in <code>master</code> and needs to be reworked. It is anticipated this will complete before Apache TomEE 8.0.0 final. +</td> +</tr> +</table> +</div> </div> </div> Modified: websites/staging/tomee/trunk/content/master/examples/mp-jwt-bean-validation.html ============================================================================== --- websites/staging/tomee/trunk/content/master/examples/mp-jwt-bean-validation.html (original) +++ websites/staging/tomee/trunk/content/master/examples/mp-jwt-bean-validation.html Sat Sep 7 14:30:44 2019 @@ -98,6 +98,18 @@ <div class="paragraph"> <p>TomEE has a fun feature that allows the use of Bean Validation as an alternative or compliment to the <code>@RolesAllowed</code> annotation. The motivation of the feature is that <code>JsonWebToken</code> is effectively a bean and a security check is ultimately an act of producing a boolean result using some minimal input. It is a perfect problem for Bean Validation.</p> </div> +<div class="admonitionblock caution"> +<table> +<tr> +<td class="icon"> +<i class="fa icon-caution" title="Caution"></i> +</td> +<td class="content"> +This feature has been temporarily removed in <code>master</code> and needs to be reworked. It is anticipated this will complete before Apache TomEE 8.0.0 final. +</td> +</tr> +</table> +</div> <div class="paragraph"> <p>The feature ultimately allows you to implement a method like this:</p> </div>