[netbeans-samples~samples:69] (Commit message missing)

  • From: ondrej58@kenai.com
  • To: commits@netbeans-samples.kenai.com
  • Subject: [netbeans-samples~samples:69] (Commit message missing)
  • Date: Wed, 16 Sep 2009 20:43:13 +0000

Project:    netbeans-samples
Repository: samples
Revision:   69
Author:     ondrej58
Date:       2009-09-16 20:43:08 UTC
Link:       

Log Message:
------------



Revisions:
----------
69


Added Paths:
------------
NB68/catalog/web/resources/images/harmony.jpg
NB68/catalog/README_files/0-Connect-DB.png
NB68/catalog/web/resources/images/mario.jpg
NB68/catalog/web/resources/images/faith-s.jpg
NB68/catalog/web/resources/images/cat1.gif
NB68/catalog/src/java/web
NB68/catalog/web/WEB-INF/sun-web.xml
NB68/catalog/README_files/0-Execute-DB.png
NB68/catalog/web
NB68/catalog/web/WEB-INF/faces-config.xml
NB68/catalog/web/resources/images/paris-s.jpg
NB68/catalog/web/resources/images/bailey.jpg
NB68/catalog/src/conf
NB68/catalog/web/resources/images/monique.jpg
NB68/catalog/src/java/controller/ItemFacade.java
NB68/catalog/web/resources/images/olie-s.jpg
NB68/catalog/web/resources/js
NB68/catalog/nbproject/build-impl.xml
NB68/catalog/web/resources/images/thaicat-s.jpg
NB68/catalog/README_files/showdetail.jpg
NB68/catalog/web/resources/images/chantelle.jpg
NB68/catalog/src/java/controller/PagingInfo.java
NB68/catalog/src/java/web/messages.properties
NB68/catalog/web/resources/css
NB68/catalog/web/index.html
NB68/catalog/src/java
NB68/catalog/web/resources/images/katzen.jpg
NB68/catalog/web/resources/images/bailey-s.jpg
NB68/catalog/nbproject/ant-deploy.xml
NB68/catalog/src/java/controller/Catalog.java
NB68/catalog/web/resources/images/chantelle-s.jpg
NB68/catalog/web/resources/images/charlie-s.jpg
NB68/catalog/web/WEB-INF
NB68/catalog/nbproject/genfiles.properties
NB68/catalog/web/resources/images/mimi.jpg
NB68/catalog/web/resources/images/cat7.gif
NB68/catalog/web/resources/images/anthony.jpg
NB68/catalog/web/resources/images/cat11.gif
NB68/catalog/web/resources/images/monique-s.jpg
NB68/catalog/web/resources/images/cat4.gif
NB68/catalog/web/resources/images/katzen-s.jpg
NB68/catalog/web/resources/images/gaetano.jpg
NB68/catalog/web/resources/css/styles.css
NB68/catalog/web/resources/images/cat10.gif
NB68/catalog/src/java/model
NB68/catalog/README_files/ViewTabData.jpg
NB68/catalog/web/detail.xhtml
NB68/catalog/web/resources/images/bob-s.jpg
NB68/catalog/web/resources/images/elkie.jpg
NB68/catalog/README_files/0-Select-DB.png
NB68/catalog/web/resources/images/faith.jpg
NB68/catalog/web/resources/images/simba.jpg
NB68/catalog/web/resources/images/Thumbs.db
NB68/catalog/web/resources/images/cat3.gif
NB68/catalog/web/resources/images/princess.jpg
NB68/catalog/web/resources/images/cat9.gif
NB68/catalog/build.xml
NB68/catalog/src/java/controller
NB68/catalog
NB68/catalog/web/resources/images/princess-s.jpg
NB68/catalog/web/WEB-INF/web.xml
NB68/catalog/web/resources/images/anthony-s.jpg
NB68/catalog/web/resources/images/olie.jpg
NB68/catalog/web/resources/images/cat2.gif
NB68/catalog/web/resources/images
NB68/catalog/web/resources/images/paris.jpg
NB68/catalog/nbproject/project.xml
NB68/catalog/web/resources
NB68/catalog/catalog.sql
NB68/catalog/web/resources/images/mimi-s.jpg
NB68/catalog/web/resources/images/mario-s.jpg
NB68/catalog/web/resources/images/gaetano-s.jpg
NB68/catalog/web/resources/images/simba-s.jpg
NB68/catalog/README_files/Thumbs.db
NB68/catalog/nbproject/project.properties
NB68/catalog/README_files/0-Run-DB.png
NB68/catalog/src/java/model/Item.java
NB68/catalog/README_files
NB68/catalog/README.html
NB68/catalog/web/resources/images/charlie.jpg
NB68/catalog/web/resources/images/cat6.gif
NB68/catalog/web/resources/images/banner_logo.gif
NB68/catalog/web/resources/images/cat8.gif
NB68/catalog/extra
NB68/catalog/web/resources/images/cat5.gif
NB68/catalog/README_files/resources.jpg
NB68/catalog/web/resources/images/cat12.gif
NB68/catalog/web/list.xhtml
NB68/catalog/nbproject
NB68/catalog/src
NB68/catalog/web/resources/images/harmony-s.jpg
NB68/catalog/web/resources/images/elkie-s.jpg
NB68/catalog/web/resources/images/thaicat.jpg
NB68/catalog/src/conf/persistence.xml
NB68/catalog/test
NB68/catalog/README_files/petcatjsf2.jpg
NB68/catalog/web/resources/images/bob.jpg


Diffs:
------
Index: NB68/catalog/README_files/0-Select-DB.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: NB68/catalog/README_files/0-Select-DB.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: NB68/catalog/README_files/showdetail.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: NB68/catalog/README_files/showdetail.jpg
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: NB68/catalog/README_files/petcatjsf2.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: NB68/catalog/README_files/petcatjsf2.jpg
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: NB68/catalog/README_files/0-Execute-DB.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: NB68/catalog/README_files/0-Execute-DB.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: NB68/catalog/README_files/Thumbs.db
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: NB68/catalog/README_files/Thumbs.db
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: NB68/catalog/README_files/0-Run-DB.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: NB68/catalog/README_files/0-Run-DB.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: NB68/catalog/README_files/resources.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: NB68/catalog/README_files/resources.jpg
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: NB68/catalog/README_files/ViewTabData.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: NB68/catalog/README_files/ViewTabData.jpg
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: NB68/catalog/README_files/0-Connect-DB.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: NB68/catalog/README_files/0-Connect-DB.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: NB68/catalog/README.html
===================================================================
--- NB68/catalog/README.html    (revision 0)
+++ NB68/catalog/README.html    (revision 69)
@@ -0,0 +1,915 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+
+  
+  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
+  <title>Java EE 6 Pet Catalog</title>
+
+  
+</head><body>
+
+<h1><br>
+</h1>
+<h2>Java EE 6 Pet Catalog with GlassFish v3 
+</h2>
+<br>
+This Pet Catalog app demonstrates a web application that
+uses JSF 2.0, Java EE 6, with GlassFish<br>
+<h2>Running the Pet Catalog Application</h2>
+<ol>
+  <li>Download and install&nbsp;<span style="text-decoration: underline;"><a 
href="http://bits.netbeans.org/netbeans/6.8/m1/";>NetBeans IDE 6.8 with
+GlassFish v3 </a></span>(Glassfish v3 preview is Java EE 6
+Preview)&nbsp;
+. <br>
+  </li>
+</ol>
+<br>
+<h3>Create the Catalog Item database table<br>
+</h3>
+In order to run the sample code you first have to create and fill
+in&nbsp; the Item database table. <br>
+<br>
+Instructions are provided for Java DB. The Java DB database is
+installed with Sun GlassFish Enterprise Server. The SQL script works
+with MySQL also. <br>
+<br>
+<ol>
+  <li>Start NetBeans IDE <br>
+  </li>
+  <li>Ensure that GlassFish is registered in the NetBeans IDE, as
+follows:
+    <ul>
+      <li>Click the Services tab in the NetBeans IDE.</li>
+      <li>Expand the Servers node. You should see GlassFish v2 in
+the list of servers. If <span style="font-weight: bold;">not</span>,
+register GlassFish v2 as follows:
+        <ul style="margin-left: 40px;" type="square">
+          <li>Right-click the Servers node and select Add Server.
+This opens an Add Server Instance wizard.</li>
+          <li>Select GlassFish v2 in the server list of the
+wizard
+and click the Next button.</li>
+          <li>Enter the location information for the server and
+click
+the Next button.</li>
+          <li>Enter the admin name and password and click the
+Finish
+button.</li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+  <li>Start the Java DB database as follows:
+    <ul>
+      <li>Click the Services tab in the NetBeans IDE.</li>
+      <li>Expand the databases node. You should see the Java DB
+database in the list of databases.
+
+    <p><img src="README_files/0-Select-DB.png" alt=""></p>
+</li>
+</ul>
+  </li>
+  <li>Right-click the database connection node
+(jdbc:derby://localhost:1527/sample[app on APP]) and choose
+Connect...&nbsp;
+    <p><img  alt="" src="README_files/0-Connect-DB.png"></p>
+  </li>
+  <li>You might be prompted for a userid and password. Enter userid <span 
style="font-weight: bold;">app</span> and&nbsp; password <span 
style="font-weight: bold;">app</span> .<br>
+  </li>
+  <li>Right click on the database connection node
+(jdbc:derby://localhost:1527/sample[app on APP]) and select&nbsp;
+Execute Command...&nbsp;
+    <p><img alt="" src="README_files/0-Execute-DB.png"></p>
+  </li>
+  <li>Copy the contents of the <code>catalog.sql</code>
+file in the <span style="font-weight: bold;">catalog</span>
+directory and paste the contents into
+the SQL command window. </li>
+  <li>Click the Run SQL button in the task bar at the top
+to execute the query.<br>
+(Note it is normal to get an error message when running the SQL script
+the first time: 'DROP TABLE' cannot be performed on 'ITEM' because it
+does not exist.)
+    <p><img alt="" src="README_files/0-Run-DB.png"></p>
+  </li>
+  <li>
+You can view the contents of a table or column by right-clicking the
+table or column and selecting View Data as shown&nbsp; below:<br>
+    <span class="sp10"> </span><br>
+<!-- Start Figure 13 --> <a name="fig13"></a>
+    <table border="0" cellpadding="2" cellspacing="0" width="600">
+      <tbody>
+        <tr>
+          <td class="grey3" align="center"><img 
src="README_files/ViewTabData.jpg" alt="Viewing the Contents of a Table" 
style="border: 0px solid ; width: 600px; height: 196px;">
+          <div class="pad3"> <span class="dkcaption1"><strong>Figure
+13.</strong> <em>Viewing the Contents of a Table</em></span></div>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+  </li>
+  
+</ol>
+<h3><br>
+</h3>
+<h3>Running the Sample solution:<br>
+</h3>
+
+If you want to run the sample solution, you have to create the catalog
+database tables first as described above. <br>
+<span class="sp10"></span><br>
+<ol>
+  <li>Open the <code>catalog</code> project as follows:
+    <ul>
+      <li>In NetBeans IDE, click Open Project in the File menu.
+This opens the Open Project dialog.</li>
+      <li>Navigate in the Open Project dialog to the 
<code>catalog&nbsp;</code>
+directory and click the Open Project button.</li>
+    </ul>
+    <span class="sp10"> </span><br>
+In response, the IDE opens the <code>catalog</code> project.&nbsp;
+You can view the logical structure of the project in the Projects
+window (Ctrl-1). </li>
+  <li>Run the <code>catalog</code> by right-clicking on the 
<code>catalog</code>
+project in the Projects window and selecting Run Project. The NetBeans
+IDE compiles the application, deploys it on Glassfish, and brings up
+the default page in your browser.&nbsp; (at
+http://localhost:8080/catalog/).</li>
+  <li>If you have problems, open the<span style="font-weight: bold;">
+catalog/setup/sun-resources.xml</span> file and verify that the
+property values it specifies match those of the database you created.
+Edit the property values as necessary.</li>
+</ol>
+<h2> </h2>
+<h2><br>
+</h2>
+<a 
href="https://techdayscode.dev.java.net/servlets/ProjectDocumentList?folderID=9890";>
+</a>
+
+<h3>Explanation of the usage of JSF 2.0 and Java EE 6 in a sample Store
+Catalog Application</h3>
+The image below shows the Catalog Listing page, which allows a user to
+page through a list of items
+in a store. <br>
+<br>
+<div style="margin-left: 40px;"> <img alt="" style="width: 472px; height: 
541px;" src="README_files/petcatjsf2.jpg"><br>
+</div>
+<br>
+<h3>JSF 2.0 Facelets XHTML instead of JSP <br>
+</h3>
+For JSF 2.0, Facelets XHTML is the preferred way to declare JSF Web
+Pages. JSP is supported for backwards compatibility, but not all JSF
+2.0 features will be available for views using JSP as their page
+declaration language.&nbsp; JSF 2.0 Facelets has some nice features
+like templating (similar in functionality to Tiles) and composite
+components, which I'm not going to discuss here but you can read about
+that in this article: <a 
href="http://www.ibm.com/developerworks/java/library/j-jsf2fu2/index.html";>http://www.ibm.com/developerworks/java/library/j-jsf2fu2/index.html</a>
+and in this Tech Tip <a 
href="/enterprisetechtips/entry/true_abstraction_composite_ui_components">Composite
+UI Components in JSF 2.0.</a><br>
+<span style="font-weight: bold;"><br>
+<br>
+The Catalog application's resources</span><br>
+<br>
+JSF 2.0 standardizes how to define web resources. Resources are any
+artifacts that a component may need in order to be rendered properly --
+images, CSS, or JavaScript files.&nbsp; With JSF 2.0 you put resources
+in a resources
+directory or a subdirectory.<br>
+<img alt="" style="width: 297px; height: 532px;" 
src="README_files/resources.jpg"><br>
+<br>
+In your Facelets pages, you can access css files with the&nbsp;
+&lt;h:outputStylesheet&gt;,&nbsp; javascript files with the
+&lt;h:outputScript&gt; , and images with the &lt;h:graphicImage&gt; JSF
+tags. The list.xhtml uses the&nbsp;<code><span style="color: rgb(204, 0, 0); 
font-weight: bold;">
+&lt;h:outputStylesheet</span></code> tag to load the <code>styles.css 
</code>stylesheet
+, and the <code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">&lt;h:graphicImage</span></code>
+tag to display images from the resources as
+shown below:<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from:&nbsp; list.xhtml<br>
+      </strong></td>
+    </tr>
+    <tr>
+      <td> <code><br>
+      </code><code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">&lt;h:outputStylesheet</span>
+name="css/styles.css" target="body"/&gt;<br>
+      <br>
+      <span style="color: rgb(204, 0, 0); font-weight: 
bold;">&lt;h:graphicImage</span>
+library="images" name="banner_logo.gif"&nbsp; /&gt;&nbsp;&nbsp;&nbsp; 
</code><code><br>
+      <br>
+      </code></td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<br>
+The Catalog application uses a resource bundle to contain the static
+text and
+error messages used by the Facelets pages. Putting messages in a
+resource bundle makes it easier to modify and internationalize your
+Application text.&nbsp; The messages are in a properties file in a java
+package directory. <br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from:&nbsp; messages.properties&nbsp; <br>
+      </strong></td>
+    </tr>
+    <tr>
+      <td> <code></code><code><span style="color: rgb(204, 0, 0); 
font-weight: bold;"></span><br>
+      </code>Title=Pet Catalog<br>
+Next=Next<br>
+Previous=Prev<br>
+Name=Name<br>
+      <code> <span style="color: rgb(204, 0, 0); font-weight: bold;"></span>
+      </code><code><br>
+      </code></td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<br>
+The resource bundle is configured in the faces-config.xml File (you
+don't need any other
+configuration in the faces-config.xml for JSF 2.0, as explained later
+you no longer have to configure managed beans and navigation with XML).
+<br>
+<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from:&nbsp; faces-config.xml<br>
+      </strong></td>
+    </tr>
+    <tr>
+      <td> <code></code><code><span style="color: rgb(204, 0, 0); 
font-weight: bold;"></span><br>
+      </code>&lt;application&gt;<br>
+&nbsp;&nbsp;&nbsp; &lt;<span style="font-weight: 
bold;">resource-bundle</span>&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+&lt;base-name&gt;web.WebMessages&lt;/base-name&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;var&gt;<span style="color: 
rgb(0, 102, 0); font-weight: bold;">msgs</span>&lt;/var&gt;<br>
+&nbsp;&nbsp;&nbsp; &lt;/resource-bundle&gt;<br>
+&lt;/application&gt;<br>
+      <code> <span style="color: rgb(204, 0, 0); font-weight: bold;"></span>
+      </code><code><br>
+      </code></td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<br>
+<br>
+The List.xhtml facelets page uses a JSF <code style="font-weight: bold; 
color: rgb(204, 0, 0);" class="cCode">dataTable</code>
+component to display a list of
+catalog items in an html table.&nbsp; The dataTable component is useful
+when you want to show a set of
+results in a table. In a JavaServer Faces application, the <code 
style="color: rgb(204, 0, 0); font-weight: bold;" class="cCode">UIData</code>
+component
+(the superclass of dataTable)&nbsp; supports binding to a collection of
+data objects. It does the
+work of iterating over each record in the data source. The HTML <code 
style="font-weight: bold; color: rgb(204, 0, 0);" 
class="cCode">dataTable</code>
+<span style="color: rgb(204, 0, 0); font-weight: bold;">renderer</span>
+displays the data as an HTML table. <br>
+<br>
+In the list.xhtml web page the dataTable is defined as shown
+below:&nbsp;
+(Note: <span style="color: rgb(204, 0, 0); font-weight: bold;">Red</span>
+colors
+are for <span style="color: rgb(204, 0, 0); font-weight: bold;">Java 
EE</span>
+tags, annotations code,&nbsp;
+and <span style="color: rgb(0, 102, 0); font-weight: bold;">Green</span>
+is
+for <span style="color: rgb(0, 102, 0); font-weight: bold;">my code</span>
+or <span style="color: rgb(0, 102, 0); font-weight: 
bold;">variables</span>)<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from:&nbsp; list.xhtml<br>
+      </strong></td>
+    </tr>
+    <tr>
+      <td> <code><br>
+      </code><code>&lt;<span style="font-weight: bold; color: rgb(204, 0, 
0);">h:dataTable</span><span style="color: rgb(204, 0, 0);"> </span><span 
style="font-weight: bold; color: rgb(204, 0, 0);">value</span>='<span 
style="font-weight: bold;">#{<span style="color: rgb(0, 102, 
0);">catalog</span>.</span><span style="color: rgb(0, 102, 0); font-weight: 
bold;">items</span><span style="font-weight: bold;">}</span>' <span 
style="font-weight: bold; color: rgb(204, 0, 0);">var</span>='<span 
style="color: rgb(0, 102, 0); font-weight: bold;"><span style="font-family: 
monospace;">row</span></span>'
+border="1"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cellpadding="2" 
cellspacing="0"&gt;</code><code><br>
+      <br>
+      </code></td>
+    </tr>
+  </tbody>
+</table>
+<br>
+The <code style="color: rgb(204, 0, 0); font-weight: bold;" 
class="cCode">value</code> attribute of a <code style="font-weight: bold; 
color: rgb(204, 0, 0);" class="cCode">dataTable</code>
+tag references the data to be included
+in the table. The <code style="font-weight: bold; color: rgb(204, 0, 0);" 
class="cCode">var</code>
+attribute specifies a
+name that is used by the components within the <code style="font-weight: 
bold; color: rgb(204, 0, 0);" class="cCode">dataTable</code>
+tag as an alias to the data referenced in the <code style="font-weight: 
bold; color: rgb(204, 0, 0);" class="cCode">value</code>
+attribute of <code style="font-weight: bold; color: rgb(204, 0, 0);" 
class="cCode">dataTable</code>.&nbsp; In the <code style="font-weight: bold; 
color: rgb(204, 0, 0);" class="cCode">dataTable</code>
+tag from the <code class="cCode"><span style="color: rgb(0, 102, 0); 
font-weight: bold;">List</span>.jsp</code>
+page, the <code style="font-weight: bold; color: rgb(204, 0, 0);" 
class="cCode">value</code> attribute points to a list
+of catalog items. The <code style="font-weight: bold; color: rgb(204, 0, 
0);" class="cCode">var</code>
+attribute points
+to a single item in that list. As the&nbsp;<code style="color: rgb(204, 0, 
0); font-weight: bold;" class="cCode"></code><code style="font-weight: bold; 
color: rgb(204, 0, 0);" class="cCode">dataTable</code>
+component<code style="color: rgb(204, 0, 0); font-weight: bold;" 
class="cCode"></code> iterates through the list, each reference to 
<code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">dataTableItem</span></code><code class="cCode"></code> points to the 
current item in the
+list.<br>
+<br>
+<h3> JSF 2.0 Annotations instead of XML configuration</h3>
+The dataTable's <code style="font-weight: bold; color: rgb(204, 0, 0);" 
class="cCode">value</code>
+is bound to the <code><span style="font-weight: bold;"></span><span 
style="color: rgb(0, 102, 0); font-weight: bold;">items</span></code>
+property
+of the <code><span style="font-weight: bold;"><span style="color: rgb(0, 
102, 0);">catalog</span></span></code> managed
+bean. With JSF 2.0 managed beans do not have to be configured in the
+faces-config.xml file, you annotate the managed beans instead as shown
+below:<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: </strong><code><span style="font-weight: 
bold; color: rgb(0, 102, 0);">Catalog</span></code><span style="font-weight: 
bold;"></span><strong>.java</strong></td>
+    </tr>
+    <tr>
+      <td> <code><br>
+      <br>
+      <span style="color: rgb(204, 0, 0); font-weight: 
bold;">@ManagedBean</span><br style="color: rgb(204, 0, 0); font-weight: 
bold;">
+      <span style="color: rgb(204, 0, 0); font-weight: 
bold;">@SessionScoped</span><br>
+public class <span style="color: rgb(0, 153, 0); font-weight: 
bold;">Catalog</span>
+implements Serializable { <br>
+      <br>
+      </code><code><span style="font-weight: bold;"></span><br>
+      </code><code></code><br>
+      <code> <br>
+      </code> </td>
+    </tr>
+  </tbody>
+</table>
+By convention, the name of a managed bean is the same as the class
+name, with the first letter of the class name in lowercase. To specify
+a managed bean name you can use the name attribute of the ManagedBean
+annotation, like this: @ManagedBean(name = "Catalog").<br>
+<br>
+<br>
+This <code><span style="font-weight: bold; color: rgb(0, 102, 
0);">Catalog</span></code><span style="font-weight: bold;"></span> 
ManagedBean<strong> </strong><code><span style="color: rgb(0, 102, 0); 
font-weight: bold;">items</span></code>
+property is defined as shown below:<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: </strong><code><span style="font-weight: 
bold; color: rgb(0, 102, 0);">Catalog</span></code><span style="font-weight: 
bold;"></span><strong>.java</strong></td>
+    </tr>
+    <tr>
+      <td><br>
+      <span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; private
+List&lt;Item&gt; items = null; <br>
+      <br>
+&nbsp;&nbsp;&nbsp; public List&lt;Item&gt; getItems() {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (items == null) {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+getPagingInfo();<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+items = getNextItems(pagingInfo.getBatchSize(),
+pagingInfo.getFirstItem());<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return items;<br>
+&nbsp;&nbsp;&nbsp; }<br>
+      <br>
+      </span><code><br>
+      <br>
+      </code> </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<br>
+The <span style="font-family: monospace;"><span style="color: rgb(0, 102, 
0); font-weight: bold;">getItems</span></span>()
+method returns a List of item objects<code style="color: rgb(204, 0, 0); 
font-weight: bold;" class="cCode"></code>.
+The JSF <code style="font-weight: bold; color: rgb(204, 0, 0);" 
class="cCode">dataTable</code>,
+supports data binding to a
+collection of data objects.&nbsp; The <code style="font-weight: bold; color: 
rgb(204, 0, 0);" class="cCode">dataTable</code>
+object is modeled as a collection
+of row objects that can be accessed by a row index.&nbsp; The APIs
+provide mechanisms to position to a specified row index, and to
+retrieve an object that represents the data that corresponds to the
+current row index.&nbsp;&nbsp;&nbsp; <br>
+<br>
+The <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">Item</span></code>
+properties <code style="font-weight: bold;"><span style="color: rgb(0, 102, 
0);">name</span></code>, <code style="font-weight: bold;"><span style="color: 
rgb(0, 102, 0);">imagethumburl</span></code>,
+and <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">price</span></code>
+<code><span style="color: rgb(0, 102, 0); font-weight: 
bold;"></span></code>are
+displayed with the <code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">column</span></code>
+component:<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: list.xhtml<br>
+      </strong></td>
+    </tr>
+    <tr>
+      <td> <code><br>
+      <span style="font-weight: bold;">&lt;</span><span style="color: 
rgb(204, 0, 0); font-weight: bold;">h:dataTable</span><span 
style="font-weight: bold;"> var="</span><span style="color: rgb(0, 102, 0); 
font-weight: bold;">row</span><span style="font-weight: bold;">" 
value="#{<span style="color: rgb(0, 102, 
0);">catalog.items</span>}"&gt;</span><br style="font-weight: bold;">
+      </code><code style="font-weight: bold;">&nbsp; &lt;<span style="color: 
rgb(204, 0, 0);">h:column</span>&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span style="color: rgb(204, 0, 
0);">f:facet</span>
+name="<span style="color: rgb(204, 0, 0);">header</span>"&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span 
style="color: rgb(204, 0, 0);">h:outputText</span> <span style="color: 
rgb(204, 0, 0);">value</span>="#{msgs.Name}"/&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span style="color: rgb(204, 0, 
0);">h:commandLink</span>
+action="#{<span style="color: rgb(0, 102, 
0);">catalog.showDetail</span>(<span style="color: rgb(0, 102, 
0);">row</span>)}" value="#{<span style="color: rgb(0, 102, 
0);">row.name</span>}" /&gt;<br>
+&nbsp;
+&lt;/h:column&gt;</code><code style="font-weight: bold;"> <br>
+&nbsp; &lt;<span style="color: rgb(204, 0, 0);">h:column</span>&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span style="color: rgb(204, 0, 
0);">f:facet</span>
+name="<span style="color: rgb(204, 0, 0);">header</span>"&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span 
style="color: rgb(204, 0, 0);">h:outputText</span> <span style="color: 
rgb(204, 0, 0);">value</span>="#{msgs.Photo}"/&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
+      </code><code style="font-weight: bold;"><span style="color: rgb(204, 
0, 0);">&lt;h:graphicImage</span>
+library="images" name="#{<span style="color: rgb(0, 102, 
0);">row.imagethumburl</span>}"/&gt;</code><code style="font-weight: 
bold;"><br>
+&nbsp;
+&lt;/h:column&gt;</code><code><br style="font-weight: bold;">
+      <span style="font-weight: bold;">&nbsp; &lt;</span><span style="color: 
rgb(204, 0, 0); font-weight: bold;">h:column</span><span style="font-weight: 
bold;">&gt;</span><br style="font-weight: bold;">
+      <span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+&lt;</span><span style="color: rgb(204, 0, 0); font-weight: 
bold;">f:facet</span><span style="font-weight: bold;"> name="</span><span 
style="color: rgb(204, 0, 0); font-weight: bold;">header</span><span 
style="font-weight: bold;">"&gt;</span><br style="font-weight: bold;">
+      <span style="font-weight: 
bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+&lt;</span><span style="color: rgb(204, 0, 0); font-weight: 
bold;">h:outputText</span><span style="font-weight: bold;"> </span><span 
style="color: rgb(204, 0, 0); font-weight: bold;">value</span><span 
style="font-weight: bold;">="#{msgs.Price}"/&gt;</span><br 
style="font-weight: bold;">
+      <span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+&lt;/f:facet&gt;</span><br style="font-weight: bold;">
+      <span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+&lt;</span><span style="color: rgb(204, 0, 0); font-weight: 
bold;">h:outputTex</span><span style="font-weight: bold;">t </span><span 
style="color: rgb(204, 0, 0); font-weight: bold;">value</span><span 
style="font-weight: bold;">="#{</span><span style="color: rgb(0, 102, 0); 
font-weight: bold;">row.price</span><span style="font-weight: 
bold;">}"/&gt;</span><br style="font-weight: bold;">
+      <span style="font-weight: bold;">&nbsp;
+&lt;/h:column&gt;</span><br style="font-weight: bold;">
+      <span style="font-weight: bold;"> &lt;/h:dataTable&gt;</span><br>
+      <br>
+      </code> </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+The <code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">column</span></code>
+tags represent columns of data in a <code style="font-weight: bold; color: 
rgb(204, 0, 0);" class="cCode">dataTable</code>
+component. While
+the <code style="font-weight: bold; color: rgb(204, 0, 0);" 
class="cCode">dataTable</code> component is iterating over the rows of
+data, it processes
+the UIColumn component associated with each <code><span style="color: 
rgb(204, 0, 0); font-weight: bold;">column</span></code>
+tag for each row in
+the table.<br>
+<br>
+The <code style="font-weight: bold; color: rgb(204, 0, 0);" 
class="cCode">dataTable </code>component&nbsp; iterates through the
+list
+of items
+(<span style="font-family: mon;"><span style="font-weight: 
bold;"></span></span><code><span style="font-weight: bold;"><span 
style="color: rgb(0, 102, 0);"></span></span><span style="color: rgb(0, 102, 
0); font-weight: bold;">catalog.items</span></code>)&nbsp;
+and displays the&nbsp;<code><span style="font-weight: bold;"></span><span 
style="font-weight: bold;"></span></code>item (<code><span 
style="font-weight: bold;">var="</span><span style="color: rgb(0, 102, 0); 
font-weight: bold;">row</span><span style="font-weight: bold;">") 
</span></code>attribute <code><span style="color: rgb(204, 0, 0); 
font-weight: bold;">value. </span></code>Each
+time UIData iterates through the list of items, it renders one cell in
+each <code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">column</span></code>.<br>
+<br>
+The dataTable and column tags use <code><span style="color: rgb(204, 0, 0); 
font-weight: bold;">facet</span></code>
+to represent parts of the
+table that are not repeated or updated. These include <code><span 
style="color: rgb(204, 0, 0); font-weight: bold;">header</span></code>s,
+footers,
+and captions. <br>
+<br>
+<h4>Java EE 6: JSF 2.0,&nbsp; EJB 3.1, and Java Persistence API
+(JPA)&nbsp; 2.0<br>
+</h4>
+The <code><span style="font-weight: bold; color: rgb(0, 102, 
0);">Catalog</span></code><span style="font-weight: bold;"></span> 
ManagedBean annotates the field <code>private
+ItemFacade <span style="color: rgb(0, 102, 0); font-weight: 
bold;">itemFacade</span>;</code>&nbsp;
+with <code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">@EJB</span></code>
+<strong><em></em></strong>, which causes an <code><span style="color: rgb(0, 
102, 0); font-weight: bold;">itemFacade</span></code>
+EJB to be
+injected when the managed bean is instatiated. The<code><span 
style="font-weight: bold; color: rgb(0, 102, 0);">
+Catalog</span></code><span style="font-weight: bold;"></span> <code><span 
style="color: rgb(0, 102, 0); font-weight: bold;">getNextItems 
</span></code>method
+calls the <code><span style="font-weight: bold; color: rgb(0, 102, 
0);">ItemFacade
+</span></code>Stateless EJB which uses the Java
+Persistence API
+<span style="color: rgb(204, 0, 0); font-weight: bold;">EntityManager
+Query </span>object to return a list of items.
+<code></code><br>
+<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: Catalog.java</strong></td>
+    </tr>
+    <tr>
+      <td> <code> <br>
+      <span style="color: rgb(0, 0, 153); font-weight: 
bold;"></span></code><code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">@ManagedBean</span><br style="color: rgb(204, 0, 0); font-weight: 
bold;">
+      <span style="color: rgb(204, 0, 0); font-weight: 
bold;">@SessionScoped</span><br>
+public class <span style="color: rgb(0, 153, 0); font-weight: 
bold;">Catalog</span>
+implements Serializable {</code><br>
+      <code> <br>
+      <span style="color: rgb(204, 0, 0); font-weight: bold;">@EJB</span><br>
+&nbsp;&nbsp;&nbsp; private ItemFacade <span style="color: rgb(0, 102, 0); 
font-weight: bold;">itemFacade</span>;<br>
+      <br>
+&nbsp;&nbsp;&nbsp; public List&lt;Item&gt;&nbsp; <span style="color: rgb(0, 
102, 0); font-weight: bold;">getNextItems</span>(int
+maxResults, int firstResult) {&nbsp; <br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+return <span style="color: rgb(0, 102, 0); font-weight: 
bold;">itemFacade.findRange</span>(maxResults,
+firstResult); &nbsp;&nbsp;&nbsp; <br>
+&nbsp;&nbsp; }<br>
+      <br>
+      </code> </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<a href="/enterprisetechtips/entry/a_sampling_of_ejb_3"><span 
style="font-weight: bold;">EJB 3.1 No-interface local client 
View</span></a><br>
+<code></code><br>
+With EJB 3.1, local EJBs&nbsp; do not&nbsp; have to a implement
+separate interface, that is, all public methods of the bean class are
+automatically exposed to the caller.<br>
+<br>
+<a style="font-weight: bold;" 
href="/enterprisetechtips/entry/a_sampling_of_ejb_3">Simplified
+Packaging</a><br>
+<br>
+With Java EE 6, EJBs can be directly packaged in a WAR file just like
+web components. <br>
+<br>
+The <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">ItemFacade</span></code>
+EJB uses the Java
+Persistence API
+<span style="color: rgb(204, 0, 0); font-weight: bold;">EntityManager
+Query </span>object to return a list of items. The <code><span style="color: 
rgb(0, 102, 0); font-weight: bold;">ItemFacade</span></code>
+EJB annotates the field <code><span style="font-weight: bold;">private
+<span style="color: rgb(204, 0, 0);">EntityManager</span> 
em</span>;</code>&nbsp;
+with <code style="color: rgb(204, 0, 0);"><span style="font-weight: 
bold;">@PersistenceContext</span></code> <strong><em></em></strong>,
+which causes an entity manager to be
+injected when it is instatiated. <br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: ItemFacade.java</strong></td>
+    </tr>
+    <tr>
+      <td> <code> <br>
+      <span style="color: rgb(0, 0, 153); font-weight: 
bold;"></span></code><code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">@Stateless</span><span style="color: rgb(204, 0, 0); font-weight: 
bold;"></span><br>
+public class <span style="color: rgb(0, 102, 0); font-weight: 
bold;">ItemFacade</span>
+{</code><br>
+      <code> <br>
+      <span style="color: rgb(204, 0, 0); font-weight: 
bold;">@PersistenceContext</span>(unitName
+= "catalogPU")<br>
+&nbsp;&nbsp;&nbsp; private <span style="color: rgb(153, 0, 0); font-weight: 
bold;">EntityManager</span>
+em;<br>
+      <br>
+&nbsp;&nbsp;&nbsp; public List&lt;Item&gt; findRange(int maxResults,
+int firstResult) {<br>
+      <span style="color: rgb(204, 0, 0); font-weight: bold;">Query</span>
+q =
+em.createQuery("select object(o) from Item as o");<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; q.setMaxResults(maxResults);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+q.setFirstResult(firstResult);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return q.getResultList();<br>
+&nbsp;&nbsp;&nbsp; }<br>
+      <br>
+      </code> </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<h4 style="font-weight: normal;">The Java Persistence <a 
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html";>Query
+APIs</a> are used to create and execute queries that can return a
+list of results.&nbsp; The JPA Query interface provides
+support for pagination via the setFirstResult() and setMaxResults()
+methods: <code>q.<span style="color: rgb(204, 0, 0); font-weight: 
bold;">setMaxResults</span></code>(int&nbsp;maxResult)
+sets the maximum number of results to retrieve.<strong><span 
style="font-family: mon;"> </span></strong><code>q.<span style="color: 
rgb(204, 0, 0); font-weight: 
bold;">setFirstResult</span></code>(int&nbsp;startPosition)
+sets the position of the first result to retrieve.</h4>
+In the code below, we show the <code><span style="color: rgb(0, 102, 0); 
font-weight: bold;">Item</span></code>
+entity class which maps to the&nbsp; ITEM table that stores the
+item instances. This is a
+typical Java Persistence entity object. There are two requirements for
+an entity:<br>
+<ol>
+  <li>annotating the class with an <span style="color: rgb(204, 0, 0); 
font-weight: bold;">@Entity</span>
+annotation. <br>
+  </li>
+  <li> annotating&nbsp;&nbsp; the primary key identifier with <span 
style="color: rgb(204, 0, 0); font-weight: bold;">@Id </span><br>
+  </li>
+</ol>
+Because the fields name, description.... are basic mappings from the
+object fields to columns of the same name in the database table, they
+don't have to be annotated.&nbsp; The O/R&nbsp; relationships with 
<code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">Address</span></code>
+and <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">Product</span></code>
+are also annotated. For more information on
+defining JPA entities see <a 
href="http://www.apress.com/book/bookDisplay.html?bID=10093";>Pro
+EJB 3: Java Persistence API book</a>.<br>
+<br>
+<a name="code-example-2" target="bpcatalog"></a>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: Item.java</strong></td>
+    </tr>
+    <tr>
+      <td> <code><br>
+      <span style="color: rgb(204, 0, 0); font-weight: 
bold;">@Entity</span><br>
+public class <span style="color: rgb(0, 102, 0); font-weight: 
bold;">Item</span>
+implements java.io.Serializable {<br>
+      <br>
+      </code><code style="color: rgb(204, 0, 0); font-weight: 
bold;">@Id</code><code><span style="color: rgb(204, 0, 0); font-weight: 
bold;"> </span> <br>
+&nbsp;&nbsp;&nbsp; private Integer id;</code><code></code><code><br>
+&nbsp;&nbsp;&nbsp; private String name;&nbsp;&nbsp;&nbsp; <br>
+&nbsp;&nbsp;&nbsp; private String description;&nbsp;&nbsp;&nbsp; <br>
+&nbsp;&nbsp;&nbsp; private String imageurl;&nbsp;&nbsp;&nbsp; <br>
+&nbsp;&nbsp;&nbsp; private String imagethumburl;&nbsp; <br>
+&nbsp;&nbsp;&nbsp; private BigDecimal price;<br>
+      <span style="color: rgb(204, 0, 0); font-weight: 
bold;">@ManyToOne</span><span style="color: rgb(204, 0, 0);"> </span><br>
+&nbsp;&nbsp;&nbsp; private <span style="color: rgb(0, 102, 0); font-weight: 
bold;">Address</span>
+address;<br>
+      </code><code> <span style="color: rgb(204, 0, 0); font-weight: 
bold;">@ManyToOne</span><br>
+&nbsp;&nbsp;&nbsp; private <span style="color: rgb(0, 102, 0); font-weight: 
bold;">Product</span>
+product;</code><br>
+      <code> <br>
+&nbsp;&nbsp;&nbsp; public Item() { }<br>
+      </code><br>
+      <code>&nbsp;&nbsp;&nbsp; public String getName() {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+return name;<br>
+&nbsp;&nbsp;&nbsp; }</code><code><br>
+&nbsp;&nbsp;&nbsp; public void setName(String name) {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+this.name = name;<br>
+&nbsp;&nbsp;&nbsp; }</code><code> <br>
+      </code><code><br>
+&nbsp; &nbsp; ... <br>
+}&nbsp;&nbsp;&nbsp; <br>
+      <br>
+      </code> </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<br>
+<br>
+The <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">Catalog</span></code>
+ManagedBean pages through the list of <code><span style="color: rgb(0, 102, 
0); font-weight: bold;">Item</span></code>s
+by
+maintaining the PagingInfo.firstItem and PagingInfo.batchSize
+attributes and passing these as
+parameters to the&nbsp; <code><span style="color: rgb(0, 102, 0); 
font-weight: bold;"></span></code><code><span style="color: rgb(0, 102, 0); 
font-weight: bold;">getNextItems</span></code>(firstItem,
+batchSize) method.
+The <code><span style="font-weight: bold; color: rgb(0, 102, 
0);">catalog</span></code>'s
+scope&nbsp; is
+defined with the annotation <code><span style="color: rgb(204, 0, 0); 
font-weight: bold;">@SessionScoped</span></code>,
+a JSF Managedbean
+with session scope will be stored in the session meaning that the
+bean's properties will stay alive for the life of the Http Session.<br>
+<br>
+<br>
+A JSF <code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">commandButton</span></code>
+is&nbsp; used to provide a button to click on to
+display the next page of items.&nbsp; The <code><span style="color: rgb(204, 
0, 0); font-weight: bold;">commandButton</span></code>
+tag is used to submit an <span style="color: rgb(204, 0, 0); font-weight: 
bold;">action event</span>
+to the application.&nbsp; <br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: list.xhtml</strong></td>
+    </tr>
+    <tr>
+      <td> <code><br style="color: rgb(204, 0, 0); font-weight: bold;">
+      <span style="color: rgb(204, 0, 0); font-weight: 
bold;">&nbsp;&lt;h:commandButton</span>
+      <span style="color: rgb(204, 0, 0); font-weight: 
bold;">action</span>="#{<span style="font-family: mon;"><span 
style="font-weight: bold;"></span></span><span style="color: rgb(0, 102, 0); 
font-weight: bold;">catalog.next</span>}"
+value="#{msgs.Next}" /&gt;&nbsp;&nbsp;&nbsp;<br>
+      </code> <br>
+      </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+This <code class="cCode"><span style="color: rgb(204, 0, 0); font-weight: 
bold;">commandButton action</span>
+</code>attribute
+references the <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">catalog</span></code>
+Managed bean <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">next</span></code>()
+method which calculates
+the
+next page's first row number&nbsp; and returns a logical outcome
+String, which causes the <span style="color: rgb(0, 102, 0); font-weight: 
bold;">list.</span>xhtml
+page
+to display the next page's
+list&nbsp;.
+The <code><span style="font-weight: bold; color: rgb(0, 102, 
0);">catalog</span></code>
+<code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">next</span></code>
+method is defined as shown below:<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: </strong><code><span style="font-weight: 
bold; color: rgb(0, 102, 0);">catalog</span></code><strong>.java</strong></td>
+    </tr>
+    <tr>
+      <td> <br>
+      <code>&nbsp;&nbsp; public String <span style="color: rgb(0, 102, 0); 
font-weight: bold;">next</span>() {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (firstItem + batchSize
+&lt; itemCount()) {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+firstItem += batchSize;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "<span style="color: rgb(0, 102, 
0); font-weight: bold;">list</span>";<br>
+&nbsp;&nbsp; } <br>
+      </code> <br>
+      </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<h3> JSF 2.0 Simplified Navigation<br>
+</h3>
+<br>
+The JavaServer Faces<span style="color: rgb(204, 0, 0); font-weight: bold;"> 
2.0&nbsp; </span><code style="color: rgb(204, 0, 0); font-weight: 
bold;">NavigationHandler</code>
+convention adds .xhtml to the logical outcome of the action method (in
+this example <code style="color: rgb(0, 102, 0); font-weight: 
bold;">list</code>)
+and
+loads that file, in this case, it loads the <code style="font-weight: 
bold;"><span style="color: rgb(0, 102, 0);">list</span>.xhtml</code>
+page after this method returns. If the action doesn't begin with a
+forward slash (/), JSF assumes that it's a relative path.&nbsp; You can
+specify an absolute path by adding the slash like this "/items/list".<br>
+<br>
+<br>
+A JSF <code><span style="color: rgb(204, 0, 0); font-weight: 
bold;">commandLink</span></code>
+is&nbsp; used to provide a link to click on to
+display a page with the <code style="font-weight: bold;"><span style="color: 
rgb(0, 102, 0);">item</span></code> details. This&nbsp;<code 
style="font-weight: bold;" class="cCode"><span style="color: rgb(204, 0, 
0);">commandLink
+action</span></code><code class="cCode"> </code>attribute&nbsp;
+references The <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">catalog</span></code>
+<span style="font-family: mon;"><span style="font-weight: 
bold;"></span></span><code><strong style="color: rgb(0, 102, 0); font-weight: 
bold;">showDetail()</strong></code>
+method:<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: list.xhtml</strong></td>
+    </tr>
+    <tr>
+      <td> <code><br>
+&nbsp;&nbsp; &lt;h:column&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;f:facet name="header"&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:outputText
+value="Name"/&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/f:facet&gt;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h:<span style="color: rgb(204, 0, 
0); font-weight: bold;">commandLink action</span>="#{<span style="color: 
rgb(0, 102, 0); font-weight: bold;">catalog.</span><strong style="color: 
rgb(0, 102, 0); font-weight: bold;">showDetail(row)</strong>}"
+value="#{row.name}"/&gt;&nbsp;&nbsp;&nbsp;<br>
+&nbsp;&nbsp; &lt;/h:column&gt; <br>
+      </code> <br>
+      </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<a style="font-weight: bold;" 
href="http://weblogs.java.net/blog/cayhorstmann/archive/2009/07/say_sayonara_to_1.html";>With
+JSF 2.0 you can now specify parameters in method expressions.</a> The 
<code><span style="font-weight: bold; color: rgb(204, 0, 
0);">dataTable</span><span style="color: rgb(204, 0, 0);"></span></code> 
<code><strong style="color: rgb(0, 102, 0); font-weight: 
bold;">row</strong></code>
+object associated with the selected <code><span style="color: rgb(204, 0, 
0); font-weight: bold;"></span></code>link
+is passed as a parameter in the&nbsp;&nbsp;<code><span style="color: 
rgb(204, 0, 0); font-weight: bold;"></span></code><code>"#{<span 
style="color: rgb(0, 102, 0); font-weight: bold;">catalog.</span><strong 
style="color: rgb(0, 102, 0); font-weight: 
bold;">showDetail(row)</strong>}"</code><code></code>
+method
+expression. <br>
+The <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">Catalog</span></code>
+<code><strong style="color: rgb(0, 102, 0); font-weight: 
bold;">showDetail()</strong></code>
+method&nbsp; gets the <code><span style="color: rgb(0, 102, 0); font-weight: 
bold;">item</span></code>
+data from the
+input parameter,
+and returns a string which causes the <span style="color: rgb(0, 102, 0); 
font-weight: bold;">detail</span>.xhtml
+page to display
+the item details :<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: </strong><code><span style="font-weight: 
bold; color: rgb(0, 102, 0);">Catalog</span></code><strong>.java
+      </strong></td>
+    </tr>
+    <tr>
+      <td> <code><br>
+&nbsp;&nbsp;&nbsp; public String <span style="color: rgb(0, 102, 0); 
font-weight: bold;">showDetail</span>(Item
+item)
+{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.item = item;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "detail";<br>
+&nbsp;&nbsp;&nbsp; }<br>
+      </code> <br>
+      </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+The JavaServer Faces <code style="color: rgb(204, 0, 0); font-weight: 
bold;">NavigationHandler</code>
+adds .xhtml to the logical outcome of the action, <code><span style="color: 
rgb(0, 102, 0); font-weight: bold;">detail</span></code><code style="color: 
rgb(0, 102, 0); font-weight: bold;"></code> and loads
+that file. In this case, the
+JavaServer Faces implementation loads the <code style="font-weight: 
bold;"><span style="color: rgb(0, 102, 0);">detail</span>.xhtml</code>
+page after this method returns.<br>
+<br>
+The detail.xhtml uses the <code><span style="color: rgb(204, 0, 0); 
font-weight: bold;">outputText</span></code>
+component to display the <code><span style="font-weight: bold; color: rgb(0, 
102, 0);">catalog</span></code>
+ManagedBean's <code><span style="font-weight: bold; color: rgb(0, 102, 
0);">item</span></code>
+properties:<br>
+<br>
+<table class="examplecode" border="1" cellpadding="2" cellspacing="0">
+  <tbody>
+    <tr class="bg-white">
+      <td><strong>Code Sample from: detail.xhtml</strong></td>
+    </tr>
+    <tr>
+      <td> <code> <br>
+&nbsp;&nbsp;&nbsp;
+&lt;h:<span style="color: rgb(204, 0, 0); font-weight: 
bold;">outputText</span>
+value="#{<span style="color: rgb(0, 102, 0); font-weight: 
bold;">catalog.item.name</span>}"
+title="Name" /&gt;<br>
+&nbsp;&nbsp;&nbsp;
+&lt;h:outputText value="#{catalog.item.description}"
+title="Description"/&gt;<br>
+&nbsp;&nbsp;&nbsp; &lt;h:graphicImage library="images"
+name="#{catalog.item.imageurl}" title="Imageurl" /&gt;</code><code><br>
+&nbsp;&nbsp;&nbsp;
+&lt;h:outputText value="#{</code><code>catalog</code><code>.item.price}"
+title="Price" /&gt;<br>
+&nbsp;&nbsp;&nbsp;
+&lt;h:outputText 
value="#{</code><code>catalog</code><code>.item.address.city}"
+title="Address" /&gt;<br>
+&nbsp;&nbsp;&nbsp;
+&lt;h:outputText 
value="#{</code><code>catalog</code><code>.item.contactinfo.email}"
+title="Address"/&gt;
+&nbsp; </code> <br>
+      <br>
+      </td>
+    </tr>
+  </tbody>
+</table>
+<br>
+<div style="margin-left: 5px;">
+    <img alt="" style="width: 782px; height: 759px;" 
src="README_files/showdetail.jpg"><br>
+</div>
+<br>
+<br>
+<h3><a href="/alexismp/entry/lightweight_glassfish">GlassFish
+v3 is a lightweight server</a></h3>
+<ul>
+  <li>OSGi-based; Embedded API; RESTful admin API; Lightweight and fast
+startup; </li>
+  <li>iterative development cycle "edit-save-refresh browser":
+    <ul>
+      <li>Incremental compile of all JSF 2.0 artifacts when you save. </li>
+    </ul>
+    <ul>
+      <li>Auto-deploy of all web or Java EE 6 artifacts</li>
+    </ul>
+  </li>
+  <li>Session retention: maintain sessions across
+re-deployments</li>
+</ul>
+<br>
+<span style="font-weight: bold;"></span><br>
+<span style="font-weight: bold;">Conclusion</span><br>
+This concludes the sample application which demonstrates a pet catalog
+web application which uses Java EE 6, GlassFish v3 and MySQL<span 
style="color: rgb(0, 0, 153); font-weight: bold;"></span>.<br>
+<br>
+<br>
+<br>
+<h2 style="margin-left: 40px;">For more information see the following
+resources:</h2>
+<ul>
+  <li><a href="/enterprisetechtips/entry/a_sampling_of_ejb_3">A
+Sampling of EJB 3.1</a></li>
+  <li><a href="http://java.sun.com/javaee/technologies/javaee6.jsp";>Java
+EE 6 Technologies</a><br>
+  </li>
+  <li><a href="https://javaserverfaces.dev.java.net/";>JSF 2.0 Home page
+Project Mojarra</a></li>
+  <li><a href="http://java.sun.com/javaee/javaserverfaces/";>SDN
+JavaServer Faces Page</a><br>
+  </li>
+  <li><a 
href="http://www.ibm.com/developerworks/java/library/j-jsf2fu1/index.html";>JSF
+2 fu, Part 1: Streamline Web application development</a></li>
+  <li><a 
href="/enterprisetechtips/entry/true_abstraction_composite_ui_components">Composite
+UI Components in JSF 2.0</a><br>
+  </li>
+  <li><a 
href="http://java.sun.com/javaee/6/docs/firstcup/doc/p5.html";>Creating
+Your First Java EE 6 Application</a></li>
+  <li><a href="http://weblogs.java.net/blog/rogerk/";>Roger Kitain's
+Blog (co-spec lead for JSF 2.0)</a></li>
+  <li><a href="http://weblogs.java.net/blog/edburns/";>Ed Burns's Blog
+(co-spec lead for JSF 2.0)</a></li>
+  <li><a 
href="http://weblogs.java.net/blog/cayhorstmann/archive/2009/07/say_sayonara_to_1.html";>Cay
+Horstmann's Blog: JSF 2.0 specifying parameters in method expressions</a><br>
+  </li>
+  <li><a 
href="http://refcardz.dzone.com/refcardz/javaserver-faces-20";>JavaServer
+Faces 2.0 Ref Card</a><br>
+  </li>
+  <li><a href="http://weblogs.java.net/blog/driscoll/";>Jim Driscoll's
+Blog</a></li>
+  <li><a href="/alexismp/entry/lightweight_glassfish">Top
+reasons why GlassFish v3 is a lightweight server</a></li>
+  <li><a 
href="http://java.dzone.com/articles/what-you-can-expect-from-glass";>What
+You Can Expect From GlassFish v3</a></li>
+  <li><a href="http://www.apress.com/book/view/1430219548";>Beginning
+Java&#8482; EE 6 Platform with GlassFish&#8482; 3: From Novice to 
Professional Book</a><br>
+  </li>
+</ul>
+<br>
+<br>
+<br>
+
+</body></html>
\ No newline at end of file
Index: NB68/catalog/nbproject/project.properties
===================================================================
--- NB68/catalog/nbproject/project.properties   (revision 0)
+++ NB68/catalog/nbproject/project.properties   (revision 69)
@@ -0,0 +1,71 @@
+build.classes.dir=${build.web.dir}/WEB-INF/classes
+build.classes.excludes=**/*.java,**/*.form
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=
[truncated due to length]



[netbeans-samples~samples:69] (Commit message missing)

ondrej58 09/16/2009
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close