Introduction to Reusable Content

19-4 Web User Interface Developers Guide for Oracle Application Development Framework When you consume a page fragment in a JSF page, at the part of the page that will use the page fragment contents, you insert the jsp:include tag to include the desired page fragment file, as shown in Example 19–2 , which is abbreviated code from the index.jspx page. Example 19–2 File Explorer Index JSF Page Includes Fragments ?xml version=1.0 encoding=utf-8? jsp:root xmlns:jsp=http:java.sun.comJSPPage version=2.0 xmlns:f=http:java.sun.comjsfcore xmlns:af=http:xmlns.oracle.comadffacesrich xmlns:trh=http:myfaces.apache.orgtrinidadhtml jsp:directive.page contentType=texthtml;charset=utf-8 f:view . . . af:document id=fileExplorerDocument title={explorerBundle[global.branding_name]} af:form id=mainForm -- Popup menu definition -- jsp:include page=fileExplorerpopups.jspx jsp:include page=fileExplorerhelp.jspx . . . f:facet name=header af:group -- The file explorer header with all the menus and toolbar buttons -- jsp:include page=fileExplorerheader.jspx af:group f:facet f:facet name=navigators af:group -- The auxiliary area for navigating the file explorer -- jsp:include page=fileExplorernavigators.jspx af:group f:facet f:facet name=contentViews af:group -- Show the contents of the selected folder in the folders navigator -- jsp:include page=fileExplorercontentViews.jspx af:group f:facet . . . af:form af:document f:view jsp:root When you modify a page fragment, the pages that consume the page fragment are automatically updated with the modifications. With pages built from page fragments, when you make layout changes, it is highly probable that modifying the page fragments alone is not sufficient; you may also have to modify every page that consumes the page fragments. Creating and Reusing Fragments, Page Templates, and Components 19-5 Like complete JSF pages, page fragments can also be based on a page template, as shown in Example 19–3 . For information about creating and applying page templates, see Section 19.3, Using Page Templates, and Section 19.3.3, How to Create JSF Pages Based on Page Templates. Example 19–3 Page Fragment Based on a Template ?xml version=1.0 encoding=windows-1252? jsp:root xmlns:jsp=http:java.sun.comJSPPage version=2.0 xmlns:af=http:xmlns.oracle.comadffacesrich xmlns:f=http:java.sun.comjsfcore af:pageTemplate viewId=someTemplateDefinition.jspx . . . af:pageTemplate jsp:root

19.2.1 How to Create a Page Fragment

Page fragments are just like any JSF page, except you do not use the f:view or document tags in page fragments. You can use the Create JSF Page Fragment wizard to create page fragments. When you create page fragments using the wizard, JDeveloper uses the extension .jsff for the page fragment files. If you do not use the wizard, you can use .jspx as the file extension as the File Explorer application does; there is no special reason to use .jsff other than quick differentiation between complete JSF pages and page fragments when you are working in the Application Navigator in JDeveloper. To create a page fragment: 1. In the Application Navigator, right-click the folder where you wish to create and store page fragments and choose New.

2. In the Categories tree, select the JSF node, in the Items pane select JSF Page

Fragment , and click OK. 3. Enter a name for the page fragment file.

4. Accept the default directory for the page fragment, or choose a new location.

By default, JDeveloper saves page fragments in the project’s public_html directory in the file system. For example, you could change the default directory to public_htmlfragments.

5. You can have your fragment pre-designed for you by using either a template or a

Quick Start Layout. ■ If you want to create a page fragment based on a page template, select the Page Template radio button and then select a template name from the Note: If the consuming page uses ADF Model data binding, the included page fragment will use the binding container of the consuming page. Only page fragments created as part of ADF bounded task flows can have their own binding container. For information about ADF bounded task flows, see the Getting Started With ADF Task Flows chapter of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework.