What Happens When You Create a Page Fragment

Creating and Reusing Fragments, Page Templates, and Components 19-9 template layout using various components, you use the facetRef tag to reference the named facets within those components where content can eventually be inserted into the template by page authors. For example, the fileExplorerTemplate template contains a facet for copyright information and another facet for application information, as shown in Example 19–6 . Example 19–6 Facet Definition in a Template facet description [CDATA[Area to put a commandLink to more information about the application.]] description facet-nameappAboutfacet-name facet facet description [CDATA[The copyright region of the page. If present, this area typically contains an outputText component with the copyright information.]] description facet-nameappCopyrightfacet-name facet In the layout section of the template as shown in Example 19–7 , a panelGroupLayout component contains a table whose cell contains a reference to the appCopyright facet and another facet contains a reference to the appAbout facet. This is where a page developer will be allowed to place that content. Example 19–7 Facet References in a Page Template af:panelGroupLayout layout=vertical afh:tableLayout width=100 afh:rowLayout afh:cellFormat af:facetRef facetName=appCopyright afh:cellFormat afh:rowLayout afh:tableLayout af:facetRef facetName=appAbout af:panelGroupLayout While the pageTemplateDef tag describes all the information and components needed in a page template definition, the JSF pages that consume a page template use the pageTemplate tag to reference the page template definition. Example 19–7 shows how the index.jspx page references the fileExplorerTemplate template, provides values for the template’s attributes, and places content within the template’s facet definitions. Note: To avoid component ID collisions at runtime, each named facet can be referenced only once in the layout section of the page template definition. That is, you cannot use multiple facetRef tags referencing the same facetName value in the same template definition. 19-10 Web User Interface Developers Guide for Oracle Application Development Framework At design time, page developers using the template can insert content into the appCopyright facet, using the f:facet tag, as shown in Example 19–8 Example 19–8 Using Page Templates Facets in a JSF Page af:pageTemplate id=fe viewId=fileExplorertemplatesfileExplorerTemplate.jspx f:attribute name=documentTitle value={explorerBundle[global.branding_name]} f:attribute name=headerSize value=70 f:attribute name=navigatorsSize value=370 . . . f:facet name=appCopyright -- Copyright info about File Explorer demo -- af:outputFormatted value={explorerBundle[about.copyright]} f:facet . . . af:pageTemplate At runtime, the inserted content is displayed in the right location on the page, as indicated by af:facetRef facetName=appCopyright in the template definition. Page template attributes specify the component properties for example, headerGlobalSize that can be set or modified in the template. While facet element information is used to specify where in a template content can be inserted, attribute element information is used to specify what page attributes are available for passing into a template, and where in the template those attributes can be used to set or modify template properties. For the page template to reference its own attributes, the pageTemplateDef tag must have a var attribute, which contains an EL variable name for referencing each attribute defined in the template. For example, in the fileExplorerTemplate template, the value of var on the pageTemplateDef tag is set to attrs. Then in the layout section of the template, an EL expression such as {attrs.someAttributeName} is used in those component attributes where page authors are allowed to specify their own values or modify default values. For example, the fileExplorerTemplate template definition defines an attribute for the header size, which has a default int value of 100 pixels as shown in Example 19–9 . Example 19–9 Page Template AttributeDefinition attribute description Specifies the number of pixels tall that the global header content should consume. description attribute-nameheaderGlobalSizeattribute-name attribute-classintattribute-class Note: You cannot run a page template as a run target in JDeveloper. You can run the page that uses the page template.