12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 11 ■ PAGES AND COMPONENTSFigure 11-8 shows the result of the newBook.xhtml page being bound to the layout.xhtml template,which is the same as that shown previously in Figure 11-1.Figure 11-8. The newBook.html page <strong>with</strong> the layout.xhtml templateResource ManagementMost of the components may need external resources in order to be rendered properly. needs an external image to display, can also display an image as abutton, references an external <strong>Java</strong>Script file, and components can apply CSS styles(<strong>with</strong> ). In JSF, a resource is a static element that can be transmitted tocomponents so they can be displayed (images) or processed (<strong>Java</strong>Script, CSS) by the browser.Previous versions of JSF had no facility for serving resources. When you wanted to provide aresource, you had to put it in the WEB-INF directory so that the client’s browser could access it. Theproblem was that, if you wanted to update it, you had to replace the file in the directory and havedifferent directories to render localized resources (for example, an image <strong>with</strong> English or Portuguesetext). JSF 2.0 has support for this functionality, so you can now put your resources directly under theresources directory or package them into a separate jar (<strong>with</strong> an optional version and/or locale). Theresource can be placed in the web application root under the path:resources/or under a jar file in the WEB-INF/lib directory:WEB-INF/lib/{*.jar}/META-INF/resources/ consists of several subfolders, specified as follows:[localePrefix/][libraryName/][libVersion/]resourceName[/resourceVersion]336

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!