SQL Zone is brought to you in partnership with:

As a Java Architect at Sun Microsystems, Carol McDonald has spoken at various conferences including JavaOne, Java University, Sun Tech Days, Sun Network, Sun Code Camps, JDJEdge, and JUGs including Machester, Boston, Maine, Cologne, FAA, Richmond, Memphis, D.C... Carol blogs about the latest technologies that she is speaking about at http://weblogs.java.net/blog/caroljmcdonald/. Before returning to Sun in 2007, Carol worked 2 1/2 yrs as an Architect on massive OLTP Spring/hibernate application to manage > 10 mill loans for the consumer credit division of a leading automoblile manufacturer and a leading bank. Before joining Sun the first time in 1999 Carol worked on Pharmaceutical Intranet applications for Roche in Switzerland, a Telecom Network Management Application for Digital (now HP) in France, a X.400 Email Server for IBM in Germany, and as a student intern for the National Security Agency. Carol holds a M.S. in Computer Science from the University of Tennessee, a B.S. in Geology from Vanderbilt University, and is a Sun Certified Java Architect and Java Language Programmer. Carol is also Fluent in French and German. Carol has posted 11 posts at DZone. View Full User Profile

Java EE 6 Pet Catalog with GlassFish and MySQL

08.12.2009
| 11513 views |
  • submit to reddit

JSF 2.0 Simplified Navigation

The JavaServer Faces 2.0  NavigationHandler convention adds .xhtml to the logical outcome of the action method (in this example list) and loads that file, in this case, it loads the list .xhtml page after this method returns. If the action doesn't begin with a forward slash (/), JSF assumes that it's a relative path.  You can specify an absolute path by adding the slash like this "/items/list".

A JSF commandLink is  used to provide a link to click on to display a page with the item details. This commandLink action attribute  references The catalog showDetail() method:

  <h:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<h:commandLink action="#{catalog.showDetail(row)}" value="#{row.name}"/>
</h:column>

With JSF 2.0 you can now specify parameters in method expressions. The dataTable row object associated with the selected link is passed as a parameter in the  "#{catalog.showDetail(row)}" method expression.

The Catalog showDetail() method  gets the item data from the input parameter, and returns a string which causes the detail.xhtml page to display the item details :

    public String showDetail(Item item) {
this.item = item;
return "detail";
}

The JavaServer Faces NavigationHandler adds .xhtml to the logical outcome of the action, detail and loads that file. In this case, the JavaServer Faces implementation loads the detail.xhtml page after this method returns.

The detail.xhtml uses the outputText component to display the catalog ManagedBean's item properties:

    <h:outputText value="#{catalog.item.name}" title="Name" />
<h:outputText value="#{catalog.item.description}" title="Description"/>
<h:graphicImage library="images" name="#{catalog.item.imageurl}" title="Imageurl" />
<h:outputText value="#{catalog.item.price}" title="Price" />
<h:outputText value="#{catalog.item.address.city}" title="Address" />
<h:outputText value="#{catalog.item.contactinfo.email}" title="Address"/>





GlassFish v3 is a lightweight server

  • OSGi-based; Embedded API; RESTful admin API; Lightweight and fast startup;
  • iterative development cycle "edit-save-refresh browser":
    • Incremental compile of all JSF 2.0 artifacts when you save.
    • Auto-deploy of all web or Java EE 6 artifacts
  • Session retention: maintain sessions across re-deployments


Published at DZone with permission of its author, Carol Mcdonald.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Reza Rahman replied on Wed, 2009/08/12 - 12:28pm

Carol,

Great job and thanks for posting this.

Cheers,

Reza

kelly jason replied on Thu, 2009/08/13 - 6:30am

LV short for the Louis Vuitton (LVMH),but more well-known is the emerging monogram of capital letters monogramed with louis vuitton.Louis Vuitton’s success is to seek for the valued customers to create a “family” feeling. Louis Vuitton monogram canvas products from generation to generation. No matter what time of the products you used to repair Louis Vuitton conservation, Louis Vuitton stores are dedicated to be duty-bound to help.So that three generations can continue to own a brand product, which is a continuation of the vitality of a brand of great significance.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.