LinkedIn
Copied!

Table of Contents

onlyonce JavaServer Page tag

Use the onlyonce JSP tag to indicate that text within the body of the tag is to be included in the stream processing output only the first time that an onlyonce tag of that name is found.

This tag is primarily useful in complex HTML streams to prevent multiple definitions of JavaScript functions.

When to use

When entering HTML source code directly into the HTML tab of a control rule (or similar form), you can minimize the size of the resulting HTML document with the <pega:onlyonce > and <pega:static > tags. See Including only one copy of JavaScript code in More about control rules.

Example

For example, this tag is named Alpha.

<!-- define scripts -->
<pega:onlyonce name="Alpha" >
The work item id is <pega:reference name=".pyID">
</pega:onlyonce >

During stream processing, if another onlyonce tag named Alpha appears, the body of the second (and later) tags are skipped over and not processed.

Complete syntax

In the syntax presentations below:

  • JSP delimiters <pega: and </pega: mark the start and end of the tag.
  • Replace any text in italics with your choice of value of that type.
<pega:onlyonce name="name" >
HTML, XML or JavaScript code to process only once
</pega:onlyonce >

The name attribute is required.

Attribute Description
name Set the name attribute to an arbitrary non-blank text value. Case is significant. During stream processing, second and later appearances of an onlyonce tag with this name cause the body of the tag to be treated as a comment, contributing nothing to the stream results.

JavaServer Page Tags

Suggest Edit
Did you find this content helpful?

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.