Advanced Customization > Info*Engine User’s Guide > Info*Engine Custom Tag Reference > Info*Engine Tags > Core Library Tags > unit
  
unit
The unit tag allows you to group a sequence of webjects, tasks, or Java code so that the group is executed as a unit. Within the unit, you can supply the main body and can also define the following nested tags to explicitly code special parts of the unit:
The init tag block supplies the initialization for the unit. The code between the start and end init tag executes first in the unit.
The success tag block provides a way to specify code that executes only when the code in the body of the unit has completed successfully.
The failure tag block provides a way to specify code that executes only when the code in the body of the unit has failed. You can include multiple failure tag blocks in which you can specify error processing for specific errors.
The main body of a unit consists of all webjects, tasks, and Java code within the unit start and end tags, but outside of the nested init, success, and failure tag blocks.
The placement of the init, success, and failure tag blocks in the unit have no significance. When the unit executes, the code in the init tag block executes first regardless of where it is in the unit. If it completes successfully, then the code in the body of the unit executes in the order it is presented in the code, starting at the beginning of the unit. If the body completes successfully, then the code in the success tag block executes. If any code in the body fails, then the failure tags in the unit are checked to determine if processing for that error has been provided. If you provide error processing for the error that has occurred, then that code executes.
If an exception occurs in a success block, the exception is thrown and the unit is not processed. If an exception occurs in the body of the unit, then it is processed by a failure tag (if one is defined for the exception) or by a general failure tag. If an error in the body of a unit is not caught through a failure tag, the error is not handled.
You can nest this tag in other unit tag blocks and in init, success, and failure tag blocks.
You can nest one init tag block, one success tag block, and one or more failure tag blocks in this tag block. You can also nest multiple webject, task, unit, and parallel tags in this tag block.
For additional information about the init, success, and failure tags, see the section that corresponds to each tag.
Scriptlets that are nested in unit, init, success, and failure tag blocks are not processed on JSP pages the same way they are processed in the Info*Engine task processor. Use the following guidelines to determine when you can nest scriptlets in these tags:
You can nest scriptlets within tag blocks in a standalone task.
You should not nest scriptlets in any tag block on a JSP page. Instead, create standalone tasks that contain the scriptlets. You can execute these tasks from the JSP page by using the Info*Engine task tag.
For additional information about scriptlets, see Scriptlets.
* 
Embedded HTML is not supported within unit tags in JSPs.
Syntax
<ie:unit>
.
. (webject, task, init, unit, parallel, success, and failure tag blocks.)
.
</ie:unit>
Example
The following example declares that the page uses tags from the Info*Engine core tag library and that the tags have the ie prefix. The example unit tag groups the main body containing the Query-Objects webject with a success and failure block. The Query-Objects webject executes and, if it completes successfully, then the success block executes. If it does not complete successfully, then the failure block executes:
<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
prefix="ie" %>

<ie:unit>

<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="adapter"/>
<ie:param name="CLASS" data="salesemp"/>
<ie:param name="WHERE" data="()"/>
<ie:param name="GROUP_OUT" data="sales">
</ie:webject>

<ie:success>
<ie:webject name="Display-Table" type="DSP">
<ie:param name="GROUP_IN" data="sales"/>
<ie:param name="ATTRIBUTE" data="ename,phone,title" DELIM=","/>
<ie:param name="HEADER" data="Name,Telephone,Title" DELIM=","/>
</ie:webject>
</ie:success>

<ie:failure>
<ie:webject name="Create-Group" type="GRP">
<ie:param name="ELEMENT" data="FAILURE=query failed"/>
<ie:param name="GROUP_OUT" data="failure"/>
</ie:webject>
<ie:webject name="Display-Table" type="DSP">
<ie:param name="GROUP_IN" data="failure"/>
<ie:param name="ATTRIBUTE" data="FAILURE"/>
</ie:webject>
</ie:failure>

</ie:unit>