Tsu Civil

Páginas: 14 (3281 palabras) Publicado: 18 de diciembre de 2012
JSF 2.0, JPA, GlassFish and MySQL
07.31.2009
| 22599 views |

inShare
*
*
*
*
* 0
inShare
*
This Pet Catalog app explains a web application that uses JSF 2.0, JPA, GlassFish and MySQL. I took this example  GlassFish and MySQL, Part 2: Building a CRUD Web Application With Data Persistence and modified it to use some of the new features JSF 2.0. 
*Download the sample code
The image below shows the Catalog Listing page, which allows a user to page through a list of items in a store.

JSF 2.0 Facelets XHTML instead of JSP
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. 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: http://www.ibm.com/developerworks/java/library/j-jsf2fu2/index.html and in this Tech Tip Composite UI Components in JSF 2.0.
The Catalog application's resources
JSF 2.0 standardizes how to defineweb resources. Resources are any artifacts that a component may need in order to be rendered properly -- images, CSS, or JavaScript files.  With JSF 2.0 you put resources in a resources directory or a subdirectory.

In your Facelets pages, you can access css files with the  <h:outputStylesheet>,  javascript files with the <h:outputScript> , and images with the <h:graphicImage>JSF tags. The list.xhtml uses the  <h:outputStylesheet tag to load the styles.css stylesheet , and the <h:graphicImage tag to display images from the resources as shown below:
view source
print?
1.<h:outputStylesheet name="css/styles.css" target="body"/>
2.<h:graphicImage library="images" name="banner_logo.gif"  />  
The Catalog application uses a resource bundle to containthe 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.  The messages are in a properties file in a java package directory.
view source
print?
1.Title=Pet Catalog
2.Next=Next
3.Previous=Prev
4.Name=Name
The resource bundle is configured in the faces-config.xml File (you don'tneed 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).
view source
print?
1.<application>
2.<resource-bundle>
3.<base-name>web.WebMessages</base-name>
4.<var>msgs</var>
5.</resource-bundle>
6.</application>
The List.xhtml facelets page usesa JSF dataTable component to display a list of catalog items in an html table.  The dataTable component is useful when you want to show a set of results in a table. In a JavaServer Faces application, the UIData component (the superclass of dataTable)  supports binding to a collection of data objects. It does the work of iterating over each record in the data source. The HTML dataTable rendererdisplays the data as an HTML table.
In the list.xhtml web page the dataTable is defined as shown below:  (Note: Red colors are for Java EE tags, annotations code,  and Green is for my code or variables)
view source
print?
1.<h:dataTable value='#{catalog.items}' var='row' border="1"
2.cellpadding="2" cellspacing="0">
The value attribute of a dataTable tag references the data to beincluded in the table. The var attribute specifies a name that is used by the components within the dataTable tag as an alias to the data referenced in the value attribute of dataTable.  In the dataTable tag from the List.jsp page, the value attribute points to a list of catalog items. The var attribute points to a single item in that list. As the dataTable component iterates through the list, each...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Tsu Construcción Civil
  • tsu construcción civil
  • Tsu Construcción Civil
  • Diferencia entre ing y tsu civil
  • TSU en Construcción civil
  • Tsu En Construccion Civil
  • tsu en construccion civil
  • Tsu Construccion Civil

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS