diff --git a/docs/chapters/batch.adoc b/docs/chapters/batch.adoc index 17a4215..baa7a2d 100644 --- a/docs/chapters/batch.adoc +++ b/docs/chapters/batch.adoc @@ -346,32 +346,34 @@ Replace `` section with `content' name such that it looks like: + [source, xml] ---- - -

Movie Sales

- - - - - - - #{s.id} - - - - - - #{s.amount} - - - - - -
+ + +

Movie Sales

+ + + + + + + #{s.id} + + + + + + #{s.amount} + + + + + +
+
---- + This code displays the show identifier and sales from that show in a diff --git a/docs/chapters/jaxrs.adoc b/docs/chapters/jaxrs.adoc index d1d30c5..d4e41f2 100644 --- a/docs/chapters/jaxrs.adoc +++ b/docs/chapters/jaxrs.adoc @@ -118,16 +118,18 @@ Replace `` section with `content' name such that it looks like: + [source, xml] ---- - - - - - - - - - - + + + + + + + + + + + + ---- + This code fragment invokes `getMovies` method from `MovieClientBean`, diff --git a/docs/chapters/jms.adoc b/docs/chapters/jms.adoc index 48adb6b..cf6bf89 100644 --- a/docs/chapters/jms.adoc +++ b/docs/chapters/jms.adoc @@ -222,24 +222,26 @@ Replace the `` section with `content' name such that it looks like: + [source, xml] ---- - -

Points

- - Queue size: -

- - - - - - - + + +

Points

+ + Queue size: +

+ + + + + + + + ---- + Click on the yellow bulb to resolve namespace prefix/URI mapping for `h:` diff --git a/docs/chapters/jsf.adoc b/docs/chapters/jsf.adoc index 47ef3bb..7f4fb6e 100644 --- a/docs/chapters/jsf.adoc +++ b/docs/chapters/jsf.adoc @@ -51,22 +51,24 @@ Replace `` section with `content' name such that it looks like: + [source, xml] ---- - -

Pick a movie

- - - - - - -
+ + +

Pick a movie

+ + + + + + +
+
---- + The code builds an HTML form that displays the list of movies as radio @@ -86,8 +88,9 @@ Specify the class name as `Booking' and the package name as + Add `@Named` class-level annotation to make the class EL-injectable. + -Add `@FlowScoped("booking")` to define the scope of bean as the flow. The bean -is automatically activated and passivated as the flow is entered or exited. +Add `@FlowScoped("booking")` to define the scope of bean as the flow. The bean is automatically activated and passivated as the flow is entered or exited. ++ +Add `implements Serializable` to the class as beans with `@FlowScoped` annotation need to be passivation capable, and thus serializable. + Add the following field: + @@ -139,18 +142,20 @@ Replace `` section with `content' name such that it looks like: + [source, xml] ---- - -

Show Timings for #{booking.movieName}

- - - - - - - - - -
+ + +

Show Timings for #{booking.movieName}

+ + + + + + + + + +
+
---- + This code builds an HTML form that displays the chosen movie name and @@ -246,28 +251,30 @@ Replace `' section with `content' name such that it looks like: + [source, xml] ---- - - - -

No theater found, choose a different time

- - Movie name: #{booking.movieName}

- Starts at: #{booking.startTime}

- - - - -

Confirm ?

- - Movie name: #{booking.movieName}

- Starts at: #{booking.startTime}

- Theater: #{booking.theater}

- - - - - - + + + + +

No theater found, choose a different time

+ + Movie name: #{booking.movieName}

+ Starts at: #{booking.startTime}

+ + + + +

Confirm ?

+ + Movie name: #{booking.movieName}

+ Starts at: #{booking.startTime}

+ Theater: #{booking.theater}

+ + + + + + + ---- + The code displays the selected movie, show timing, and theater if @@ -292,15 +299,17 @@ Replace `` section with `content' name such that it looks like: + [source, xml] ---- - -

Reservation Confirmed

- - Movie name: #{booking.movieName}

- Starts at: #{booking.startTime}

- Theater: #{booking.theater}

-

- - + + +

Reservation Confirmed

+ + Movie name: #{booking.movieName}

+ Starts at: #{booking.startTime}

+ Theater: #{booking.theater}

+

+ + + ---- + This code displays the movie name, show timings, and the selected diff --git a/docs/chapters/json.adoc b/docs/chapters/json.adoc index 349b5f8..4140903 100644 --- a/docs/chapters/json.adoc +++ b/docs/chapters/json.adoc @@ -199,29 +199,31 @@ Replace `` section with `content' name such that it looks like: + [source, xml] ---- - -

Add a New Movie

- - - - - - - - - - - - - - -
Movie Id:
Movie Name:
Movie Actors:
- -
-
+ + +

Add a New Movie

+ + + + + + + + + + + + + + +
Movie Id:
Movie Name:
Movie Actors:
+ +
+
+
---- + This code creates a form to accept input of `id`, `name`, and `actors` of a diff --git a/docs/chapters/websocket.adoc b/docs/chapters/websocket.adoc index 9ad70fd..12f1b02 100644 --- a/docs/chapters/websocket.adoc +++ b/docs/chapters/websocket.adoc @@ -105,33 +105,35 @@ In this file, remove sections where name attribute value is Replace `` section with `content' name such that it looks like: + [source,xml] - -
- - - - - - - - -
- Chat Log
- -
- Users
- -
- - -

- -

-
-
- -
+ + +
+ + + + + + + + +
+ Chat Log
+ +
+ Users
+ +
+ + +

+ +

+
+
+ +
+
+ The code builds an HTML form that has two textareas – one to display the chat log and the other to display the list of users currently logged. A diff --git a/docs/javaee7-hol.html b/docs/javaee7-hol.html index 885e68c..883fe06 100644 --- a/docs/javaee7-hol.html +++ b/docs/javaee7-hol.html @@ -1531,33 +1531,35 @@

4. Chat Room (Java API for WebSocket)

-
<ui:define name="content">
-    <form action="">
-        <table>
-            <tr>
-                <td>
-                    Chat Log<br/>
-                    <textarea readonly="true" rows="6" cols="50" id="chatlog"></textarea>
-                </td>
-                <td>
-                    Users<br/>
-                    <textarea readonly="true" rows="6" cols="20" id="users"></textarea>
-                </td>
-            </tr>
-            <tr>
-                <td colspan="2">
-                    <input id="textField" name="name" value="Duke" type="text"/>
-                    <input onclick="join();" value="Join" type="button"/>
-                    <input onclick="send_message();" value="Send" type="button"/><p/>
-                    <input onclick="disconnect();" value="Disconnect" type="button"/>
-                </td>
-            </tr>
-        </table>
-    </form>
-    <div id="output"></div>
-        <script language="javascript" type="text/javascript"
-            src="${facesContext.externalContext.requestContextPath}/chat/websocket.js"></script>
-</ui:define>
+
<ui:composition template="../WEB-INF/template.xhtml">
+    <ui:define name="content">
+        <form action="">
+            <table>
+                <tr>
+                    <td>
+                        Chat Log<br/>
+                        <textarea readonly="true" rows="6" cols="50" id="chatlog"></textarea>
+                    </td>
+                    <td>
+                        Users<br/>
+                        <textarea readonly="true" rows="6" cols="20" id="users"></textarea>
+                    </td>
+                </tr>
+                <tr>
+                    <td colspan="2">
+                        <input id="textField" name="name" value="Duke" type="text"/>
+                        <input onclick="join();" value="Join" type="button"/>
+                        <input onclick="send_message();" value="Send" type="button"/><p/>
+                        <input onclick="disconnect();" value="Disconnect" type="button"/>
+                    </td>
+                </tr>
+            </table>
+        </form>
+        <div id="output"></div>
+            <script language="javascript" type="text/javascript"
+                src="${facesContext.externalContext.requestContextPath}/chat/websocket.js"></script>
+    </ui:define>
+</ui:composition>
@@ -2240,32 +2242,34 @@

5. Ticket Sales (Batch Applications for the Java Platform)

-
<ui:define name="content">
-    <h1>Movie Sales</h1>
-    <h:form>
-        <h:dataTable value="#{salesBean.salesData}" var="s" border="1">
-            <h:column>
-                <f:facet name="header">
-                    <h:outputText value="Show ID" />
-                </f:facet>
-                #{s.id}
-            </h:column>
-            <h:column>
-                <f:facet name="header">
-                    <h:outputText value="Sales" />
-                </f:facet>
-                #{s.amount}
-            </h:column>
-        </h:dataTable>
-        <h:commandButton
-            value="Run Job"
-            action="sales"
-            actionListener="#{salesBean.runJob()}"/>
-        <h:commandButton
-            value="Refresh"
-            action="sales" />
-    </h:form>
-</ui:define>
+
<ui:composition template="../WEB-INF/template.xhtml">
+    <ui:define name="content">
+        <h1>Movie Sales</h1>
+        <h:form>
+            <h:dataTable value="#{salesBean.salesData}" var="s" border="1">
+                <h:column>
+                    <f:facet name="header">
+                        <h:outputText value="Show ID" />
+                    </f:facet>
+                    #{s.id}
+                </h:column>
+                <h:column>
+                    <f:facet name="header">
+                        <h:outputText value="Sales" />
+                    </f:facet>
+                    #{s.amount}
+                </h:column>
+            </h:dataTable>
+            <h:commandButton
+                value="Run Job"
+                action="sales"
+                actionListener="#{salesBean.runJob()}"/>
+            <h:commandButton
+                value="Refresh"
+                action="sales" />
+        </h:form>
+    </ui:define>
+</ui:composition>
@@ -2499,16 +2503,18 @@

6. View and Delete Movie (Java API for RESTful Web Services)

-
<ui:define name="content">
-    <h:form prependId="false">
-        <h:selectOneRadio value="#{movieBackingBean.movieId}" layout="pageDirection">
-            <c:forEach items="#{movieClientBean.movies}" var="m">
-                <f:selectItem itemValue="#{m.id}" itemLabel="#{m.name}"/>
-            </c:forEach>
-        </h:selectOneRadio>
-        <h:commandButton value="Details" action="movie" />
-    </h:form>
-</ui:define>
+
<ui:composition template="../WEB-INF/template.xhtml">
+    <ui:define name="content">
+        <h:form prependId="false">
+            <h:selectOneRadio value="#{movieBackingBean.movieId}" layout="pageDirection">
+                <c:forEach items="#{movieClientBean.movies}" var="m">
+                    <f:selectItem itemValue="#{m.id}" itemLabel="#{m.name}"/>
+                </c:forEach>
+            </h:selectOneRadio>
+            <h:commandButton value="Details" action="movie" />
+        </h:form>
+    </ui:define>
+</ui:composition>
@@ -3010,29 +3016,31 @@

7. Add Movie (Java API for JSON Processing)

-
<ui:define name="content">
-<h1>Add a New Movie</h1>
-<h:form>
-    <table cellpadding="5" cellspacing="5">
-        <tr>
-            <th align="left">Movie Id:</th>
-            <td><h:inputText value="#{movieBackingBean.movieId}"/></td>
-        </tr>
-        <tr>
-            <th align="left">Movie Name:</th>
-            <td><h:inputText value="#{movieBackingBean.movieName}"/> </td>
-        </tr>
-        <tr>
-            <th align="left">Movie Actors:</th>
-            <td><h:inputText value="#{movieBackingBean.actors}"/></td>
-        </tr>
-    </table>
-    <h:commandButton
-        value="Add"
-        action="movies"
-        actionListener="#{movieClientBean.addMovie()}"/>
-</h:form>
-</ui:define>
+
<ui:composition template="../WEB-INF/template.xhtml">
+    <ui:define name="content">
+    <h1>Add a New Movie</h1>
+    <h:form>
+        <table cellpadding="5" cellspacing="5">
+            <tr>
+                <th align="left">Movie Id:</th>
+                <td><h:inputText value="#{movieBackingBean.movieId}"/></td>
+            </tr>
+            <tr>
+                <th align="left">Movie Name:</th>
+                <td><h:inputText value="#{movieBackingBean.movieName}"/> </td>
+            </tr>
+            <tr>
+                <th align="left">Movie Actors:</th>
+                <td><h:inputText value="#{movieBackingBean.actors}"/></td>
+            </tr>
+        </table>
+        <h:commandButton
+            value="Add"
+            action="movies"
+            actionListener="#{movieClientBean.addMovie()}"/>
+    </h:form>
+    </ui:define>
+</ui:composition>
@@ -3436,24 +3444,26 @@

8. Movie Points (Java Message Service)

-
<ui:define name="content">
-    <h1>Points</h1>
-    <h:form>
-    Queue size:
-        <h:outputText value="#{receivePointsBean.queueSize}"/><p/>
-        <h:inputText value="#{sendPointsBean.message}"/>
-        <h:commandButton
-            value="Send Message"
-            action="points"
-            actionListener="#{sendPointsBean.sendMessage()}"/>
-    </h:form>
-    <h:form>
-        <h:commandButton
-            value="Receive Message"
-            action="points"
-            actionListener="#{receivePointsBean.receiveMessage()}"/>
-    </h:form>
-</ui:define>
+
<ui:composition template="../WEB-INF/template.xhtml">
+    <ui:define name="content">
+        <h1>Points</h1>
+        <h:form>
+        Queue size:
+            <h:outputText value="#{receivePointsBean.queueSize}"/><p/>
+            <h:inputText value="#{sendPointsBean.message}"/>
+            <h:commandButton
+                value="Send Message"
+                action="points"
+                actionListener="#{sendPointsBean.sendMessage()}"/>
+        </h:form>
+        <h:form>
+            <h:commandButton
+                value="Receive Message"
+                action="points"
+                actionListener="#{receivePointsBean.receiveMessage()}"/>
+        </h:form>
+    </ui:define>
+</ui:composition>
@@ -3643,22 +3653,24 @@

9. Show Booking (JavaServer Faces)

-
<ui:define name="content">
-    <h2>Pick a movie</h2>
-    <h:form prependId="false">
-        <h:selectOneRadio
-            value="#{booking.movieId}"
-            layout="pageDirection"
-            required="true">
-            <f:selectItems
-                value="#{movieFacadeREST.all}"
-                var="m"
-                itemValue="#{m.id}"
-                itemLabel="#{m.name}"/>
-        </h:selectOneRadio>
-        <h:commandButton id="shows" value="Pick a time" action="showtimes" />
-    </h:form>
-</ui:define>
+
<ui:composition template="../WEB-INF/template.xhtml">
+    <ui:define name="content">
+        <h2>Pick a movie</h2>
+        <h:form prependId="false">
+            <h:selectOneRadio
+                value="#{booking.movieId}"
+                layout="pageDirection"
+                required="true">
+                <f:selectItems
+                    value="#{movieFacadeREST.all}"
+                    var="m"
+                    itemValue="#{m.id}"
+                    itemLabel="#{m.name}"/>
+            </h:selectOneRadio>
+            <h:commandButton id="shows" value="Pick a time" action="showtimes" />
+        </h:form>
+    </ui:define>
+</ui:composition>
@@ -3687,8 +3699,10 @@

9. Show Booking (JavaServer Faces)

Add @Named class-level annotation to make the class EL-injectable.

-

Add @FlowScoped("booking") to define the scope of bean as the flow. The bean -is automatically activated and passivated as the flow is entered or exited.

+

Add @FlowScoped("booking") to define the scope of bean as the flow. The bean is automatically activated and passivated as the flow is entered or exited.

+
+
+

Add implements Serializable to the class as beans with @FlowScoped annotation need to be passivation capable, and thus serializable.

Add the following field:

@@ -3752,18 +3766,20 @@

9. Show Booking (JavaServer Faces)

-
<ui:define name="content">
-    <h2>Show Timings for <font color="red">#{booking.movieName}</font></h2>
-    <h:form>
-        <h:selectOneRadio value="#{booking.startTime}" layout="pageDirection" required="true">
-            <c:forEach items="#{timeslotFacadeREST.all}" var="s">
-                <f:selectItem itemValue="#{s.id},#{s.startTime}" itemLabel="#{s.startTime}"/>
-            </c:forEach>
-        </h:selectOneRadio>
-        <h:commandButton value="Confirm" action="confirm" />
-        <h:commandButton id="back" value="Back" action="booking" immediate="true"/>
-    </h:form>
-</ui:define>
+
<ui:composition template="../WEB-INF/template.xhtml">
+    <ui:define name="content">
+        <h2>Show Timings for <font color="red">#{booking.movieName}</font></h2>
+        <h:form>
+            <h:selectOneRadio value="#{booking.startTime}" layout="pageDirection" required="true">
+                <c:forEach items="#{timeslotFacadeREST.all}" var="s">
+                    <f:selectItem itemValue="#{s.id},#{s.startTime}" itemLabel="#{s.startTime}"/>
+                </c:forEach>
+            </h:selectOneRadio>
+            <h:commandButton value="Confirm" action="confirm" />
+            <h:commandButton id="back" value="Back" action="booking" immediate="true"/>
+        </h:form>
+    </ui:define>
+</ui:composition>
@@ -3871,28 +3887,30 @@

9. Show Booking (JavaServer Faces)

-
<ui:define name="content">
-    <c:choose>
-        <c:when test="#{booking.theater == 'none'}">
-            <h2>No theater found, choose a different time</h2>
-            <h:form>
-                Movie name: #{booking.movieName}<p/>
-                Starts at: #{booking.startTime}<p/>
-                <h:commandButton id="back" value="Back" action="showtimes"/>
-            </h:form>
-        </c:when>
-        <c:otherwise>
-            <h2>Confirm ?</h2>
-            <h:form>
-                Movie name: #{booking.movieName}<p/>
-                Starts at: #{booking.startTime}<p/>
-                Theater: #{booking.theater}<p/>
-                <h:commandButton id="next" value="Book" action="print"/>
-                <h:commandButton id="back" value="Back" action="showtimes"/>
-            </h:form>
-        </c:otherwise>
-    </c:choose>
-</ui:define>
+
<ui:composition template="../WEB-INF/template.xhtml">
+    <ui:define name="content">
+        <c:choose>
+            <c:when test="#{booking.theater == 'none'}">
+                <h2>No theater found, choose a different time</h2>
+                <h:form>
+                    Movie name: #{booking.movieName}<p/>
+                    Starts at: #{booking.startTime}<p/>
+                    <h:commandButton id="back" value="Back" action="showtimes"/>
+                </h:form>
+            </c:when>
+            <c:otherwise>
+                <h2>Confirm ?</h2>
+                <h:form>
+                    Movie name: #{booking.movieName}<p/>
+                    Starts at: #{booking.startTime}<p/>
+                    Theater: #{booking.theater}<p/>
+                    <h:commandButton id="next" value="Book" action="print"/>
+                    <h:commandButton id="back" value="Back" action="showtimes"/>
+                </h:form>
+            </c:otherwise>
+        </c:choose>
+    </ui:define>
+</ui:composition>
@@ -3923,15 +3941,17 @@

9. Show Booking (JavaServer Faces)

-
<ui:define name="content">
-    <h2>Reservation Confirmed</h2>
-    <h:form>
-        Movie name: #{booking.movieName}<p/>
-        Starts at: #{booking.startTime}<p/>
-        Theater: #{booking.theater}<p/>
-        <h:commandButton id="home" value="home" action="goHome" /><p/>
-    </h:form>
-</ui:define>
+
<ui:composition template="../WEB-INF/template.xhtml">
+    <ui:define name="content">
+        <h2>Reservation Confirmed</h2>
+        <h:form>
+            Movie name: #{booking.movieName}<p/>
+            Starts at: #{booking.startTime}<p/>
+            Theater: #{booking.theater}<p/>
+            <h:commandButton id="home" value="home" action="goHome" /><p/>
+        </h:form>
+    </ui:define>
+</ui:composition>
diff --git a/docs/javaee7-hol.pdf b/docs/javaee7-hol.pdf index ab91662..73810e5 100644 Binary files a/docs/javaee7-hol.pdf and b/docs/javaee7-hol.pdf differ diff --git a/docs/javaee7-hol.xml b/docs/javaee7-hol.xml index b239ed1..bba9492 100644 --- a/docs/javaee7-hol.xml +++ b/docs/javaee7-hol.xml @@ -1096,33 +1096,35 @@ code. In this file, remove <ui:define> sections where name attribute value is ‘top’ and ‘left’. These sections are inherited from the template. Replace <ui:define> section with ‘content’ name such that it looks like: -<ui:define name="content"> - <form action=""> - <table> - <tr> - <td> - Chat Log<br/> - <textarea readonly="true" rows="6" cols="50" id="chatlog"></textarea> - </td> - <td> - Users<br/> - <textarea readonly="true" rows="6" cols="20" id="users"></textarea> - </td> - </tr> - <tr> - <td colspan="2"> - <input id="textField" name="name" value="Duke" type="text"/> - <input onclick="join();" value="Join" type="button"/> - <input onclick="send_message();" value="Send" type="button"/><p/> - <input onclick="disconnect();" value="Disconnect" type="button"/> - </td> - </tr> - </table> - </form> - <div id="output"></div> - <script language="javascript" type="text/javascript" - src="${facesContext.externalContext.requestContextPath}/chat/websocket.js"></script> -</ui:define> +<ui:composition template="../WEB-INF/template.xhtml"> + <ui:define name="content"> + <form action=""> + <table> + <tr> + <td> + Chat Log<br/> + <textarea readonly="true" rows="6" cols="50" id="chatlog"></textarea> + </td> + <td> + Users<br/> + <textarea readonly="true" rows="6" cols="20" id="users"></textarea> + </td> + </tr> + <tr> + <td colspan="2"> + <input id="textField" name="name" value="Duke" type="text"/> + <input onclick="join();" value="Join" type="button"/> + <input onclick="send_message();" value="Send" type="button"/><p/> + <input onclick="disconnect();" value="Disconnect" type="button"/> + </td> + </tr> + </table> + </form> + <div id="output"></div> + <script language="javascript" type="text/javascript" + src="${facesContext.externalContext.requestContextPath}/chat/websocket.js"></script> + </ui:define> +</ui:composition> The code builds an HTML form that has two textareas – one to display the chat log and the other to display the list of users currently logged. A @@ -1674,32 +1676,34 @@ expand ‘Web Pages’, ‘WEB-INF’, select ‘template.xh In this file, remove <ui:define> sections where name attribute value is ‘top’ and ‘left’. These sections are inherited from the template. Replace <ui:define> section with ‘content’ name such that it looks like: -<ui:define name="content"> - <h1>Movie Sales</h1> - <h:form> - <h:dataTable value="#{salesBean.salesData}" var="s" border="1"> - <h:column> - <f:facet name="header"> - <h:outputText value="Show ID" /> - </f:facet> - #{s.id} - </h:column> - <h:column> - <f:facet name="header"> - <h:outputText value="Sales" /> - </f:facet> - #{s.amount} - </h:column> - </h:dataTable> - <h:commandButton - value="Run Job" - action="sales" - actionListener="#{salesBean.runJob()}"/> - <h:commandButton - value="Refresh" - action="sales" /> - </h:form> -</ui:define> +<ui:composition template="../WEB-INF/template.xhtml"> + <ui:define name="content"> + <h1>Movie Sales</h1> + <h:form> + <h:dataTable value="#{salesBean.salesData}" var="s" border="1"> + <h:column> + <f:facet name="header"> + <h:outputText value="Show ID" /> + </f:facet> + #{s.id} + </h:column> + <h:column> + <f:facet name="header"> + <h:outputText value="Sales" /> + </f:facet> + #{s.amount} + </h:column> + </h:dataTable> + <h:commandButton + value="Run Job" + action="sales" + actionListener="#{salesBean.runJob()}"/> + <h:commandButton + value="Refresh" + action="sales" /> + </h:form> + </ui:define> +</ui:composition> This code displays the show identifier and sales from that show in a table by invoking SalesBean.getSalesData(). First command button allows @@ -1889,16 +1893,18 @@ expand ‘Web Pages’, ‘WEB-INF’, select ‘template.xh In this file, remove <ui:define> sections where name attribute value is ‘top’ and ‘left’. These sections are inherited from the template. Replace <ui:define> section with ‘content’ name such that it looks like: -<ui:define name="content"> - <h:form prependId="false"> - <h:selectOneRadio value="#{movieBackingBean.movieId}" layout="pageDirection"> - <c:forEach items="#{movieClientBean.movies}" var="m"> - <f:selectItem itemValue="#{m.id}" itemLabel="#{m.name}"/> - </c:forEach> - </h:selectOneRadio> - <h:commandButton value="Details" action="movie" /> - </h:form> -</ui:define> +<ui:composition template="../WEB-INF/template.xhtml"> + <ui:define name="content"> + <h:form prependId="false"> + <h:selectOneRadio value="#{movieBackingBean.movieId}" layout="pageDirection"> + <c:forEach items="#{movieClientBean.movies}" var="m"> + <f:selectItem itemValue="#{m.id}" itemLabel="#{m.name}"/> + </c:forEach> + </h:selectOneRadio> + <h:commandButton value="Details" action="movie" /> + </h:form> + </ui:define> +</ui:composition> This code fragment invokes getMovies method from MovieClientBean, iterates over the response in a for loop, and display the name of each @@ -2290,29 +2296,31 @@ Click on ‘Finish’. In this file, remove <ui:define> sections where name attribute value is ‘top’ and ‘left’. These sections are inherited from the template. Replace <ui:define> section with ‘content’ name such that it looks like: -<ui:define name="content"> -<h1>Add a New Movie</h1> -<h:form> - <table cellpadding="5" cellspacing="5"> - <tr> - <th align="left">Movie Id:</th> - <td><h:inputText value="#{movieBackingBean.movieId}"/></td> - </tr> - <tr> - <th align="left">Movie Name:</th> - <td><h:inputText value="#{movieBackingBean.movieName}"/> </td> - </tr> - <tr> - <th align="left">Movie Actors:</th> - <td><h:inputText value="#{movieBackingBean.actors}"/></td> - </tr> - </table> - <h:commandButton - value="Add" - action="movies" - actionListener="#{movieClientBean.addMovie()}"/> -</h:form> -</ui:define> +<ui:composition template="../WEB-INF/template.xhtml"> + <ui:define name="content"> + <h1>Add a New Movie</h1> + <h:form> + <table cellpadding="5" cellspacing="5"> + <tr> + <th align="left">Movie Id:</th> + <td><h:inputText value="#{movieBackingBean.movieId}"/></td> + </tr> + <tr> + <th align="left">Movie Name:</th> + <td><h:inputText value="#{movieBackingBean.movieName}"/> </td> + </tr> + <tr> + <th align="left">Movie Actors:</th> + <td><h:inputText value="#{movieBackingBean.actors}"/></td> + </tr> + </table> + <h:commandButton + value="Add" + action="movies" + actionListener="#{movieClientBean.addMovie()}"/> + </h:form> + </ui:define> +</ui:composition> This code creates a form to accept input of id, name, and actors of a movie. These values are bound to fields in MovieBackingBean. The click @@ -2619,24 +2627,26 @@ next to ‘Template:’, expand ‘Web Pages’, ‘WEB-INF& In this file, remove <ui:define> sections where name attribute value is ‘top’ and ‘left’. These sections are inherited from the template. Replace the <ui:define> section with ‘content’ name such that it looks like: -<ui:define name="content"> - <h1>Points</h1> - <h:form> - Queue size: - <h:outputText value="#{receivePointsBean.queueSize}"/><p/> - <h:inputText value="#{sendPointsBean.message}"/> - <h:commandButton - value="Send Message" - action="points" - actionListener="#{sendPointsBean.sendMessage()}"/> - </h:form> - <h:form> - <h:commandButton - value="Receive Message" - action="points" - actionListener="#{receivePointsBean.receiveMessage()}"/> - </h:form> -</ui:define> +<ui:composition template="../WEB-INF/template.xhtml"> + <ui:define name="content"> + <h1>Points</h1> + <h:form> + Queue size: + <h:outputText value="#{receivePointsBean.queueSize}"/><p/> + <h:inputText value="#{sendPointsBean.message}"/> + <h:commandButton + value="Send Message" + action="points" + actionListener="#{sendPointsBean.sendMessage()}"/> + </h:form> + <h:form> + <h:commandButton + value="Receive Message" + action="points" + actionListener="#{receivePointsBean.receiveMessage()}"/> + </h:form> + </ui:define> +</ui:composition> Click on the yellow bulb to resolve namespace prefix/URI mapping for h: prefix. @@ -2804,22 +2814,24 @@ next to ‘Template:’, expand ‘Web Pages’, ‘WEB-INF& In this file, remove <ui:define> sections with ‘top’ and ‘left’ name attributes. These sections are inherited from the template. Replace <ui:define> section with ‘content’ name such that it looks like: -<ui:define name="content"> - <h2>Pick a movie</h2> - <h:form prependId="false"> - <h:selectOneRadio - value="#{booking.movieId}" - layout="pageDirection" - required="true"> - <f:selectItems - value="#{movieFacadeREST.all}" - var="m" - itemValue="#{m.id}" - itemLabel="#{m.name}"/> - </h:selectOneRadio> - <h:commandButton id="shows" value="Pick a time" action="showtimes" /> - </h:form> -</ui:define> +<ui:composition template="../WEB-INF/template.xhtml"> + <ui:define name="content"> + <h2>Pick a movie</h2> + <h:form prependId="false"> + <h:selectOneRadio + value="#{booking.movieId}" + layout="pageDirection" + required="true"> + <f:selectItems + value="#{movieFacadeREST.all}" + var="m" + itemValue="#{m.id}" + itemLabel="#{m.name}"/> + </h:selectOneRadio> + <h:commandButton id="shows" value="Pick a time" action="showtimes" /> + </h:form> + </ui:define> +</ui:composition> The code builds an HTML form that displays the list of movies as radio button choices. The chosen movie is bound to #{booking.movieId} which @@ -2844,8 +2856,8 @@ add namespace prefix/URI mapping for h:. Repeat the same for Specify the class name as ‘Booking’ and the package name as ‘org.javaee7.movieplex7.booking’. Add @Named class-level annotation to make the class EL-injectable. -Add @FlowScoped("booking") to define the scope of bean as the flow. The bean -is automatically activated and passivated as the flow is entered or exited. +Add @FlowScoped("booking") to define the scope of bean as the flow. The bean is automatically activated and passivated as the flow is entered or exited. +Add implements Serializable to the class as beans with @FlowScoped annotation need to be passivation capable, and thus serializable. Add the following field: int movieId; @@ -2879,18 +2891,20 @@ steps used to create ‘booking.xhtml’. In this file, remove <ui:define> sections with ‘top’ and ‘left’ name attributes. These sections are inherited from the template. Replace <ui:define> section with ‘content’ name such that it looks like: -<ui:define name="content"> - <h2>Show Timings for <font color="red">#{booking.movieName}</font></h2> - <h:form> - <h:selectOneRadio value="#{booking.startTime}" layout="pageDirection" required="true"> - <c:forEach items="#{timeslotFacadeREST.all}" var="s"> - <f:selectItem itemValue="#{s.id},#{s.startTime}" itemLabel="#{s.startTime}"/> - </c:forEach> - </h:selectOneRadio> - <h:commandButton value="Confirm" action="confirm" /> - <h:commandButton id="back" value="Back" action="booking" immediate="true"/> - </h:form> -</ui:define> +<ui:composition template="../WEB-INF/template.xhtml"> + <ui:define name="content"> + <h2>Show Timings for <font color="red">#{booking.movieName}</font></h2> + <h:form> + <h:selectOneRadio value="#{booking.startTime}" layout="pageDirection" required="true"> + <c:forEach items="#{timeslotFacadeREST.all}" var="s"> + <f:selectItem itemValue="#{s.id},#{s.startTime}" itemLabel="#{s.startTime}"/> + </c:forEach> + </h:selectOneRadio> + <h:commandButton value="Confirm" action="confirm" /> + <h:commandButton id="back" value="Back" action="booking" immediate="true"/> + </h:form> + </ui:define> +</ui:composition> This code builds an HTML form that displays the chosen movie name and all the show times. #{timeslotFacadeREST.all} returns the list of all @@ -2966,28 +2980,30 @@ the steps used to create ‘booking.xhtml’. In this file, remove <ui:define> sections wht ‘top’ and ‘left’ name attributes. These sections are inherited from the template. Replace ‘<ui:define>’ section with ‘content’ name such that it looks like: -<ui:define name="content"> - <c:choose> - <c:when test="#{booking.theater == 'none'}"> - <h2>No theater found, choose a different time</h2> - <h:form> - Movie name: #{booking.movieName}<p/> - Starts at: #{booking.startTime}<p/> - <h:commandButton id="back" value="Back" action="showtimes"/> - </h:form> - </c:when> - <c:otherwise> - <h2>Confirm ?</h2> - <h:form> - Movie name: #{booking.movieName}<p/> - Starts at: #{booking.startTime}<p/> - Theater: #{booking.theater}<p/> - <h:commandButton id="next" value="Book" action="print"/> - <h:commandButton id="back" value="Back" action="showtimes"/> - </h:form> - </c:otherwise> - </c:choose> -</ui:define> +<ui:composition template="../WEB-INF/template.xhtml"> + <ui:define name="content"> + <c:choose> + <c:when test="#{booking.theater == 'none'}"> + <h2>No theater found, choose a different time</h2> + <h:form> + Movie name: #{booking.movieName}<p/> + Starts at: #{booking.startTime}<p/> + <h:commandButton id="back" value="Back" action="showtimes"/> + </h:form> + </c:when> + <c:otherwise> + <h2>Confirm ?</h2> + <h:form> + Movie name: #{booking.movieName}<p/> + Starts at: #{booking.startTime}<p/> + Theater: #{booking.theater}<p/> + <h:commandButton id="next" value="Book" action="print"/> + <h:commandButton id="back" value="Back" action="showtimes"/> + </h:form> + </c:otherwise> + </c:choose> + </ui:define> +</ui:composition> The code displays the selected movie, show timing, and theater if available. The reservation can proceed if all three are available. @@ -3005,15 +3021,17 @@ steps used to create ‘booking.xhtml’. In this file, remove <ui:define> sections wht ‘top’ and ‘left’ name attributes. These sections are inherited from the template. Replace <ui:define> section with ‘content’ name such that it looks like: -<ui:define name="content"> - <h2>Reservation Confirmed</h2> - <h:form> - Movie name: #{booking.movieName}<p/> - Starts at: #{booking.startTime}<p/> - Theater: #{booking.theater}<p/> - <h:commandButton id="home" value="home" action="goHome" /><p/> - </h:form> -</ui:define> +<ui:composition template="../WEB-INF/template.xhtml"> + <ui:define name="content"> + <h2>Reservation Confirmed</h2> + <h:form> + Movie name: #{booking.movieName}<p/> + Starts at: #{booking.startTime}<p/> + Theater: #{booking.theater}<p/> + <h:commandButton id="home" value="home" action="goHome" /><p/> + </h:form> + </ui:define> +</ui:composition> This code displays the movie name, show timings, and the selected theater. diff --git a/solution/movieplex7-1.0-SNAPSHOT.war b/solution/movieplex7-1.0-SNAPSHOT.war new file mode 100644 index 0000000..6ca561e Binary files /dev/null and b/solution/movieplex7-1.0-SNAPSHOT.war differ diff --git a/solution/movieplex7-solution.zip b/solution/movieplex7-solution.zip index 2a6a75e..0b33108 100644 Binary files a/solution/movieplex7-solution.zip and b/solution/movieplex7-solution.zip differ diff --git a/solution/movieplex7/pom.xml b/solution/movieplex7/pom.xml index 1140a79..ba0863e 100644 --- a/solution/movieplex7/pom.xml +++ b/solution/movieplex7/pom.xml @@ -37,6 +37,11 @@ false + + org.wildfly.plugins + wildfly-maven-plugin + 1.0.2.Final + diff --git a/solution/movieplex7/src/main/java/org/javaee7/movieplex7/booking/Booking.java b/solution/movieplex7/src/main/java/org/javaee7/movieplex7/booking/Booking.java index 42330d4..7d8d145 100644 --- a/solution/movieplex7/src/main/java/org/javaee7/movieplex7/booking/Booking.java +++ b/solution/movieplex7/src/main/java/org/javaee7/movieplex7/booking/Booking.java @@ -39,6 +39,7 @@ */ package org.javaee7.movieplex7.booking; +import java.io.Serializable; import java.util.List; import java.util.StringTokenizer; import javax.faces.flow.FlowScoped; @@ -54,7 +55,7 @@ */ @Named @FlowScoped("booking") -public class Booking { +public class Booking implements Serializable { int movieId; String startTime; diff --git a/starting-template/movieplex7/pom.xml b/starting-template/movieplex7/pom.xml index 2044289..286607b 100644 --- a/starting-template/movieplex7/pom.xml +++ b/starting-template/movieplex7/pom.xml @@ -37,6 +37,11 @@ false + + org.wildfly.plugins + wildfly-maven-plugin + 1.0.2.Final +