Designing Template Pagelets
Note: Template pagelets can also be created using Pagelet Wizard. We recommend that you consider using this as it provides a means for simple and convenient creation and maintenance of template pagelets.
This topic is meant to provide information about how to create template pagelets that are more complex than those that can be created using Pagelet Wizard.
See the product documentation for PeopleTools: Portal Technology
Unlike homepage pagelets, template pagelets are usually designed to work with contextual relationships—that is, template pagelets are usually required to retrieve the current target page context and display relevant information accordingly.
For examples of context aware processing, examine the template pagelets and associated features delivered with your application.
Template pagelets can be created based on either page definitions in PeopleSoft Application Designer or iScripts.
Note: Whether template pagelets are created from page definitions in Application Designer or an iScript, they will also require some PeopleCode development to retrieve information about the target page to enable context sensitivity.
The following code is for example purposes only and should not be considered as a design template.
import PTCXM_TEMPLATE_PAGELET:*;
/************************************************************************/
/* Generic Template Pagelet iScript Sample */
/* Sample code to demonstrate how to use the PTCXM_TEMPLATE_PAGELET */
/* app package classes to generate a template pagelet in iScript. */
/************************************************************************/
Function iScript_TemplatePagelet(&Type As string)
&TPRequest = create PTCXM_TEMPLATE_PAGELET:TPRequest();
&TPResponse = create PTCXM_TEMPLATE_PAGELET:TPResponse();
If &TPResponse.isThisPageletMinimized() Then
&HTML = ""; /* pagelet is minimized - only needed for hidden pagelets */
Else
If &TPRequest.isTCKeyDependant() Then
If &TPRequest.isTCAvailable() And
&TPRequest.GetNumTCKeys() > 0 Then
For &i = 1 To &TPRequest.GetNumKeys()
&KeyName = &TPRequest.GetTCKey(&i);
&KeyValue = &TPRequest.GetTCKeyValueByIndex(&i);
If All(&KeyValue) Then
/* Process key/value pair */
&HTML = &val_1; /* result of processing */
End-If;
End-For;
Else
/* Processing for key dependant - but keys not available */
&HTML = &val_2; /* result of processing */
End-If;
Else
/* Processing for non-key dependancy */
&HTML = &val_3; /* result of processing */
End-If;
End-If;
&TPResponse.WritePageletHTML(&HTML, "", "");
End-Function;
iScript-based template pagelets can be defined so that they can be hidden. When a template pagelet is hidden, no information about that pagelet will be displayed to the user, including the template boundary box and pagelet title. This is useful when you only want to display information when a specific context is detected.
To create a hidden template pagelet, you will need to write special pagelet output so that the pagelet container will only be generated when appropriate.
Instead of using the
%Response.Write method to write HTML directly, make a buffer variable
available to display the HTML code. To create the pagelet output,
a call to the method TResponse.WritePageletHTML(&HTML, "", "") should be
included.
Note: When the pagelet is minimized, Oracle recommends calling the WritePageletHTML method with a blank HTML buffer variable. When using this method, no container is created and no trace of the pagelet is visible to the end user.
When the template pagelet is registered, the attribute CANBEHIDDEN must be set with the value of TRUE.