AquaLogic User Interaction Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Creating Publisher Presentation Templates Using IDK Remote APIs

To create and validate Publisher Presentation Templates, use the IPresentationTemplateManager interface in the IDK.

Most of the code in a Presentation Template is markup that defines how the content item will be laid out and formatted. Use pcS tags to insert Publisher content. PCS tags are replaced by the referenced property during the publishing operation. All Publisher tags require the following:
  • An opening tag and a closing tag (that is, <pcs:…> </pcs:…>).
  • The opening tag must include an “expr” parameter that references a property name. The property name must be enclosed in single or double quotation marks (property names are not case-sensitive).
For more details on PCS tags, see Publisher Templating Specification.

After you have created the markup for a Presentation Template, you must create and store it using IPresentationTemplateManager so it can be used to publish content items. If published content items should not be included in the search index, set the searchable flag on the Presentation Template object to false.

Note: The IPresentationTemplateManager.validateTemplateText method can be used to find any pcS syntax errors. It is a best practice to execute this method after creating a new Presentation Template, before it is used to publish a content item.
These examples create a Presentation Template that displays values in an HTML table. The default file type is HTML; you can use the IPresentationTemplate interface to set the file extension to any value that is valid for a basic text file, including .js, .jsp, .asp, .xml, and .txt.

Java

...

StringBuffer templateBuffer = new StringBuffer("");
templateBuffer.append(" <table border='1' \n")
.append("<tr> <td> <b> Incident ID </b> </td> <td> <pcs:value expr='Incident_ID'></pcs:value> </td> </tr>\n")
.append("<tr> <td> <b>Created By </b> </td> <td> <pcs:value expr='createdBy'></pcs:value> on <pcs:value expr='created' format='MMMM d, yyyy'> </pcs:value> </td> </tr>\n")
.append("<tr> <td> <b>Resolved </b> </td> <td> <pcs:value expr='Resolved'></pcs:value> </td> </tr>\n")
.append("<tr> <td> <b>Severity </b> </td> <td> <pcs:value expr='Severity'> </pcs:value> </td> </tr>\n")
.append("<tr> <td> <b>Date Opened </b></td><td> <pcs:value expr='Date_Opened' format='MM, dd, yyyy'></pcs:value></td> </tr>\n")
.append("<tr> <td> <b>Customer Name </b> </td> <td> <pcs:value expr='Customer_Name'></pcs:value> </td> </tr>\n")
.append("<tr> <td> <b>Customer Information </b> </td> <td> <pcs:value expr='Customer_Information.name'></pcs:value></td></tr>\n")
.append("<tr> <td> <b>Product </b> </td> <td> <pcs:value expr='Product'></pcs:value></td> </tr>\n")
.append(" <tr> <td> <b>Incident Description </b> </td> <td> <pcs:value expr='Incident_Description'></pcs:value> </td> </tr>\n")
.append("<tr> <td> <b>Log File </b> </td> <td> <pcs:value expr='Log_File.name'></pcs:value></td> </tr> \n")
.append(" <tr> <td> <b>Screen Shot </b> </td><td> <pcs:value expr='Screen_Shot.name'></pcs:value> </td> </tr> \n")
.append(" </table>

// Create the Presentation Template.
presentationTemplate = ptManager.createPresentationTemplate(dataEntryTemplate.getContainingFolder(),
"Customer Support Incident Presentation Template", templateBuffer.toString());

// Store the Presentation Template.
presentationTemplate.store();

// Validate the template text before using it to publish
// content items.
String[] errorsInText = ptManager.validateTemplateText(pt, pt.getTemplateText());
if(errorsInText.length != 0)
{
System.out.println("PCS validation returned the following errors");
for(int i = 0; i < errorsInText.length; i++)
{
System.out.println("error[" + i + "]: " + errorsInText[i]); }
}
}
...

.NET (C#)

...

StringBuilder templateBuffer = new StringBuilder();
templateBuffer.Append("<table border='1'>\n")
.Append("<tr><td><b>Incident ID</b></td><td><pcs:value expr='Incident_ID'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Created By</b></td><td><pcs:value expr='createdBy'></pcs:value> on <pcs:value expr='created' format='MMMM, dd, yyyy'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Resolved</b></td><td><pcs:value expr='Resolved'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Severity</b></td><td><pcs:value expr='Severity'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Date Opened</b></td><td><pcs:value expr='Date_Opened' format='MM, dd, yyyy'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Customer Name</b></td><td><pcs:value expr='Customer_Name'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Customer Information</b></td><td><pcs:value expr='Customer_Information.name'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Product</b></td><td><pcs:value expr='Product'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Incident Description</b></td><td><pcs:value expr='Incident_Description'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Log File</b></td><td><pcs:value expr='Log_File.name'></pcs:value></td></tr>\n")
.Append("<tr><td><b>Screen Shot</b></td><td><pcs:value expr='Screen_Shot.name'></pcs:value></td></tr>\n")
.Append("</table>\n");

// Create the Presentation Template.
IPresentationTemplate presentationTemplate = ptManager.CreatePresentationTemplate(dataEntryTemplate.GetContainingFolder(), "Customer Support Incident Presentation Template", templateBuffer.ToString());

// Store the Presentation Template.
presentationTemplate.Store();

// Validate the template text before using it to publish content items.
String[] errorsInText = ptManager.ValidateTemplateText(pt, pt.TemplateText);
if(errorsInText.Length != 0)
{
Console.WriteLine("PCS validation returned the following errors");
for(int i = 0; i < errorsInText.Length; i++)
{
Console.WriteLine("error[" + i + "]: " + errorsInText[i]);
}
}
...

.NET (VB)

...
Dim templateBuffer As StringBuilder = New StringBuilder
templateBuffer.Append("<table border='1'>" + System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Incident ID</b></td><td><pcs:value expr='Incident_ID'></pcs:value></td></tr>"
+ System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Created By</b></td><td><pcs:value expr='createdBy'></pcs:value>
on <pcs:value expr='created' format='MMMM d, yyyy'></pcs:value></td></tr>" + System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Resolved</b></td><td><pcs:value expr='Resolved'></pcs:value></td></tr>"
+ System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Severity</b></td><td><pcs:value expr='Severity'></pcs:value></td></tr>"
+ System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Date Opened</b></td><td><pcs:value expr='Date_Opened'
format='MMMM d, yyyy'></pcs:value></td></tr>" + System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Customer Name</b></td><td><pcs:value expr='Customer_Name'></pcs:value></td></tr>"
+ System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Customer Information</b></td><td><pcs:value expr='Customer_Information.name'></pcs:value></td></tr>"
+ System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Product</b></td><td><pcs:value expr='Product'></pcs:value></td></tr>"
+ System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Incident Description</b></td><td><pcs:value expr='Incident_Description'></pcs:value></td></tr>"
+ System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Log File</b></td><td><pcs:value expr='Log_File.name'></pcs:value></td></tr>"
+ System.Environment.NewLine)
templateBuffer.Append("<tr><td><b>Screen Shot</b></td><td><pcs:value expr='Screen_Shot.name'></pcs:value></td></tr>"
+ System.Environment.NewLine)
templateBuffer.Append("</table>" + System.Environment.NewLine)

' Create the Presentation Template with the template text.
Dim presentationTemplate As IPresentationTemplate = ptManager.CreatePresentationTemplate(dataEntryTemplate.GetContainingFolder(),
"Customer Support Incident Presentation Template", templateBuffer.ToString())

' Store the Presentation Template.
presentationTemplate.Store()


...
' Validate the template text before using it to publish items
Dim errorsInText() As String = ptManager.ValidateTemplateText(presentationTemplate,
presentationTemplate.TemplateText)
If errorsInText.Length <> 0 Then
Console.WriteLine("Validate Template Text returned the following errors")
Dim i As Integer
For i = 0 To errorsInText.Length - 1
Console.WriteLine("error[" & i & "]: " & errorsInText(i))
Next
End If


...

  Back to Top      Previous Next