Specifying and styling column headers

To specify column headers that are different from the field names in the database, you can do so in your SQL statement that extracts the data, such as using a statement like "SELECT FROM myTable column1 AS newColumnName1, column2 AS newColumnName2...." In this case, the members are known to ReportBlox as newColumnName1 and newColumnName2. Note that member names are case-sensitive, so in your later references to these members, their cases should be respect.
Note: Oracle returns the new names in all uppercases. To preserve the cases, quote the member names:
"SELECT FROM myTable total_sq_ft AS \"Sq_Ft\", sq_ft_pct AS \"Pct\""

Another approach is to use the TextBlox. TextBlox lets you specify the display texts for the five areas in a rendered report: column headers, data, and, if the report is grouped, group headers, group footers, and group totals (see Display areas in a rendered report for these areas on a report). The <bloxreport:text> tag has nested tags for you to specify the text or add HTML code around the value/member for each of the five areas.

To specify a column header, use the TextBlox’s nested columnHeader tag. This tag has two tag attributes:
  • columnName— required; the name of the member on this column
  • text— required; the text to display for the column header. Everything you specify here will be sent to the browser for processing, including any HTML code added.

The following example sets the column header for member “Sales” to “Product Sales” and the column header for member “Units” to “Units Sold:”

<%@ taglib uri="bloxreporttld" prefix="bloxreport" 
<bloxreport:report id = "MyReport">
...
   <bloxreport:text>
      <bloxreport:columnHeader
         columnName="Sales">
         text="Product Sales" />
      <bloxreport:columnHeader
         columnName="Units"
         text="Units Sold" />
   </bloxreport:text>
...
</bloxreport:report>
You can wrap HTML code around column headers to add formatting, links, or images. The following example:
  • Renames the column header for member Cost to Unit Cost.
  • Adds a link from the header to another URL in the myApp application for additional information on the cost.
  • Adds an image info.gif that resides in the same directory as this report JSP.
    <bloxreport:text>
      <bloxreport:columnHeader
        columnName="Cost"
        text="<a href=\"/myApp/products/CostList.html\"> 
           <img src="info.gif">Unit Cost</a>" />
    </bloxreport:text>
Note: The text string for the text attribute should be on one line with no line breaks. It is broken into multiple lines due to the limited width of the printed page. When copying and pasting the code from the online version, you should remove the line breaks.

See the Saving and Exporting Data with Dynamic Query example in Blox Sampler— Relational Reporting for an live example.

TextBlox preserves your HTML code for the column header so you can use the standard HTML to format the headers. The URL and image path can be relative or absolute:
  • For absolute URLs, the string should begin with “http://”.
  • For relative URLs:
    • Starting the string with a slash (/) indicates that the URL is relative to the server root. The application context needs to be included in the URL.
    • Starting the string without a slash indicates that the URL is relative to the current document.

To add HTML code around the member name without renaming it, use the <member/> substitution variable, as shown in the following example:

<bloxreport:text>
   <bloxreport:columnHeader
      columnName="Cost"
      text="<a href=\"/myApp/products/CostList.html\"> 
         <img src="info.gif"><member/></a>"/>
</bloxreport:text>
<member/> is a substitution variable that gets substituted into the member name when the relational report HTML is sent to the browser. It is not a JSP tag.
Important: If the report is rendered in interactive mode, when users choose to rename the column header using the Column Header Context Menu, all the HTML code will appear. This could be undesirable. In addition, your users can easily overwrite your HTML code and formatting. It is recommended that you set the interactive attribute of your ReportBlox to false if you have HTML code wrapped around your column headers or footers.
Important: The text string for the text attribute should be on one line with no line breaks. It is broken into multiple lines due to the limited width of the printed page. When copying and pasting the code from the online version, you should remove the line breaks.
Tip: Avoid adding styling strings using TextBlox. Styles are output last by the Alphablox Relational Reporting engine after the data has been formatted and wrapped in text. Setting styles through the text attribute in TextBlox’s nested tags is not as efficient and can cause you confusion as the styles are overridden by styles set in style sheets and StyleBlox.
Tip: In an interactive report, if you wrap an anchor tag outside the column header text (or group headers, footers, and totals), when you mouse over the column header, the context menu will not pop up. You will need to hover somewhere else in the cell (but not the link) in order for the menu to pop up. This is the browser’s behavior. Keep this in mind as you design your report.