26 Configure the Template’s Element

back to WebCenter Sites Help

The Element screen is used to create the template's element, define the element file type (XML, JSP, or HTML), provide the element logic, and name the element. For example:

  • The Create Template Element field offers a choice of XML, JSP, or HTML file types for the element logic, and is used to seed the Element Logic field with standard stub code (which you have to include in any element that you create).

    When you use the Create Template Element field to create, for example, a .jsp file, WebCenter Sites adds JSP taglib statements and the RENDER.LOGDEP tag to the Element Logic field by default so that WebCenter Sites can log the compositional dependency between this Template asset and pages that are rendered from this element. For other file types, WebCenter Sites adds code specific to the file type. You will add your own code to the Element Logic field.

  • The Element Storage Path/Filename field names the file that holds the element logic and specifies the path to the file.

When the Template asset is saved, field values in the Element screen are written to a row (representing the element) in the ElementCatalog table.

Note:

About Selecting an Existing Element

In the steps that follow, we assume you are creating a new element for the Template asset. If, however, you are migrating assets from an earlier WebCenter Sites release and want to reuse an existing element, you have to identify the element correctly so that WebCenter Sites can find it and associate it with this Template asset.

To select an existing element, do the following:

  1. In the ElementCatalog Description field, type a description of the element.

  2. In the Element Storage Path/Filename field, enter a value according to the naming convention in the “Naming Conventions Using TemplateName” table described in the “Naming a Template Asset” topic in Developing with Oracle WebCenter Sites.

  3. In the Element Parameters field, specify the variables or arguments that can be passed to the element.

  4. Save and re-open the Template asset.

    WebCenter Sites checks for the existence of the named element:

    If the element has been correctly named, WebCenter Sites recognizes the element and displays its code in the Element Logic field.

    If the named element does not exist (or is incorrectly named), WebCenter Sites does nothing. When you inspect or edit the Template asset, WebCenter Sites displays a message stating that there is no root element in the form. As soon as you code the element and give it the correct name, WebCenter Sites detects it and associates it with the template.

In the Element screen:

  1. In the Usage field, specify the intended usage of this template, using the information in the table as a guideline.

    Usage Option Description

    Usage unspecified

    Specifies a template that generates HTML. It is unknown whether the template is a Body template (see row 2 of this table) or a url template (see row 3 of this table).

    Element is used within an HTML page

    Specifies a template that is used inside the <BODY>...</BODY> tag of an HTML page. This option characterizes the template as a Body template.

    Element is used as a layout

    Specifies a layout template that generates a complete HTML page, and is used to render assets in Web Mode.

    Element defines a whole HTML page and can be called externally

    Specifies a template that generates a complete HTML page and can be used in a url. This option characterizes the template as a url template.

    Element is streamed as raw data

    Specifies a template that generates raw binary data of an unknown type that is not HTML.

  2. In the Called Templates field, select the template(s) that this template will call (if they exist).

  3. In the Create Template Element field, do one of the following:

    • To create an .xml file, click XML. The code that is pasted in comes from the OpenMarket\Xcelerate\AssetType\Template\modelXML.xml element and can be modified to use custom default logic.

    • To create a .jsp file, click JSP. The code that is pasted in comes from the OpenMarket\Xcelerate\AssetType\Template\modelJSP.xml element and can be modified to use custom default logic.

    • To create an .html file, click HTML. The code that is pasted in comes from the OpenMarket\Xcelerate\AssetType\Template\modelHTML.xml element and can be modified to use custom default logic.

    WebCenter Sites populates the following fields:

    • Element Logic field with a header and other auto-generated code.

      For example, if you clicked the JSP button, WebCenter Sites enters a tag library directive for each of the WebCenter Sites JSP tag libraries. WebCenter Sites also sets a RENDER.LOGDEP (render:logdep) tag to mark a compositional dependency between the Template asset and any page or pagelet rendered with the template.

    • Element Storage Path/Filename field. Do not change the value of this field.

      This field displays the element file name, preceded by the path to the element file.

      When you save the Template asset, the value in the Element Storage Path/Filename field is written to the url column of the ElementCatalog table, for the row that represents the element.

  4. The Rootelement field is pre-populated with the value given in “Naming Conventions Using TemplateName” table. Do not change the value of this field. If the default value is changed, some tags that expect the default value, such as the render:calltemplate tag with the style attribute set to element, will fail.

  5. (Optional). In the ElementCatalog Description field, type a description of the element. When you save the Template asset, information in this field is written to the description column for the element entry in the ElementCatalog table.

  6. In the Element Logic field, code your element. Be sure to enter all of your code between the two cs:ftcs tags.

    If you are using JSP, remove the comments from the taglib directives that describe the tag libraries you are using.

    Note:

    Ensuring Template Sharing or a Replicable Site

    To share your Template asset or make the current site replicable, ensure the template's element logic does not directly refer to assets, asset types, attribute names, or template names. Instead, use the render:lookup tag and prescribed keys as explained in “Template Sharing and Site Replication” in Developing with Oracle WebCenter Sites. In Configure the Map you map the same keys to the asset information that must be accessed for use in the element logic.

    Calling a Template

    Templates should always be called by the render:calltemplate tag, and never the render:callelement tag or render:satellitepage tag.

  7. The Element Parameters field and Additional Element Parameters field are used to enter variables or arguments that can be passed to the element, if the site design requires them.

    • The Element Parameters field corresponds to the resdetails1 column in the ElementCatalog. When you save the template, WebCenter Sites writes the template ID (tid) to this field (i.e., to the resdetails1 column).

    • The Additional Element Parameters field corresponds to the resdetails2 column in the ElementCatalog. WebCenter Sites leaves this field blank.

    If your site design requires you to use variables in addition to tid in your template element, enter the variables into one of the fields above. Enter them as name=value pairs with multiple arguments separated by the ampersand (&) character. For example:

    MyArgument=value1&YourArgument=value2
    

    Each field supports up to 255 characters.

    For more information about variables, see “Website Development with Tag Technologies” in Developing with Oracle WebCenter Sites

  8. Click Continue to open the SiteEntry screen.