The layout template specifies the structure of the area within the page template in which the gears are rendered. The layout template is included by the page template by means of a tag (paf:layout) rather than as a file include. The layout template structures the gear area by means of a table with a single row. Each cell within the row corresponds to a column in the gear area of the page. For example, three cells would mean a three-column gear area. Within each cell, a name and a region rendering fragment for the column are specified.

There are four layout templates provided in ATG Portal:

In addition, you can create your own custom layout templates and make them available within the administration utilities by means of a layout template manifest. See Customizing Portal Appearance: Layout Template Manifests in the Creating a Custom Portal chapter for more information about creating layout template manifests.

Layout Template Example

The following code sample comes from the layout template named 25_75.jsp. The layout consists of an HTML table with a single row. Each cell within the row includes a region fragment, region.jspf, using this element:

<%@ include file="region.jspf" %>

The region fragment renders the gear’s content. See Region Rendering Fragment in this chapter for more information.

As in the page template, the layout template begins by importing the tag libraries and Java packages used in the layout.

<%@ page import="java.io.*,java.util.*,atg.portal.servlet.*,
atg.portal.framework.*,java.util.*" errorPage="/error.jsp"%>
<%@ taglib prefix="paf" uri="http://www.atg.com/taglibs/portal/paf1_3" %>
<%@ taglib prefix="dsp" uri="http://www.atg.com/taglibs/daf/dspjspELTaglib1_0" %>
<%@ taglib prefix="c"   uri="http://java.sun.com/jstl/core" %>

Next, we set the portal request and response and other variables.

<c:set var="PORTALSERVLETREQUEST"><%= Attribute.PORTALSERVLETREQUEST %></c:set>
<c:set var="PORTALSERVLETRESPONSE"><%= Attribute.PORTALSERVLETRESPONSE %></c:set>
<c:set var="portalServletRequest" value="${requestScope[PORTALSERVLETREQUEST]}"/>
<c:set var="portalServletResponse"
       value="${requestScope[PORTALSERVLETRESPONSE]}"/>
<c:set var="page"       value="${portalServletRequest.page}"/>
<c:set var="regionMap"  value="${page.regions}"/>

The next section begins the table that defines the page layout.

<center>
  <table border="0" width="96%" cellpadding="0" cellspacing="0">
    <tr>

The first cell is defined. It is allocated 25% of the page’s width, and includes the region rendering fragment.

      <td valign="top" width="25%">
        <c:set var="gears" value="${regionMap['25_75_Left'].gears}"/>
        <%@ include file="region.jspf" %>
      </td>
Region Rendering Fragment

A layout template can use a region fragment to render the contents of a column in the gear area of the page. From an HTML perspective, a region fragment corresponds to the contents of a table cell defined within the containing layout template. A region fragment contains the code that obtains a list of gears to render in the column and renders the gears.

ATG Portal provides a region rendering fragment named region.jspf. This region fragment contains the code that obtains a list of gears to be rendered in the region, and then iteratively renders each gear in the list, along with the gear’s title bar, pre-treatment, and post-treatment.

The first section of region.jspf makes the Portal Servlet Request and Portal Servlet Response attributes available, as well as setting visual style parameters.

<c:set var="PORTALSERVLETREQUEST"><%= Attribute.PORTALSERVLETREQUEST %></c:set>
<c:set var="PORTALSERVLETRESPONSE"><%= Attribute.PORTALSERVLETRESPONSE %></c:set>
<c:set var="portalServletRequest" value="${requestScope[PORTALSERVLETREQUEST]}"/>
<c:set var="portalServletResponse"
       value="${requestScope[PORTALSERVLETRESPONSE]}"/>
<c:set var="community" value="${portalServletRequest.community}"/>
<c:set var="gearTextColor" value="#${page.colorPalette.gearTextColor}"/>
<c:set var="gearBackgroundColor"
       value="#${page.colorPalette.gearBackgroundColor}"/>

The next section uses a c:forEach element to iterate through all of the gears to be displayed in the region:

<c:forEach var="gear"  items="${gears}">

For each gear, we:

Note that using a <paf:titlebar> element to include a title bar from another file or to dispatch the gear for pre- or post-treatment can be less efficient than inlining the code for the title bar or pre- or post-treatment. However, using the <paf:titlebar> element lets you separate this display element from the gear rendering code, which may make it easier to maintain or change your portal application.


Copyright © 1997, 2014 Oracle and/or its affiliates. All rights reserved. Legal Notices