JOT Templates > JOT Template Scripting

JOT Template Scripting

Conditional Content:

The If, ElseIf, and Else tokens conditionally include or skip over sections of page content. In this example, a message to preferred customers is included when the PreferredCustomer JOT Bean property is true.

    JOT.If(JOT.PreferredCustomer)
      <b>Thanks for being a Preferred Customer!</b>
    JOT.ElseIf(JOT.Not(JOT.InactiveCustomer))
      <b>We want you to become a Preferred Customer!</b>
    JOT.Else
      <b>Please activate your account!</b>
    JOT.End  <!-- [end of IF-ELSEIF-ELSE section] -->

Repeating Content:

The Repeat token repeats a section of page content, such as for a list or for each row of a table. The Next token is used to advance to the next element in a repeated section. The More token determines if there are any more elements remaining in the repeated section. In the following example, a table row is generated for each shopping cart item, followed by a table row for the total purchase price. If there are no items then the table is not shown.

    JOT.If(JOT.Items.More)
      <table>
      JOT.Repeat(JOT.Items.Next)
        <tr><td>JOT.Items.ProdcutName</td></tr>
      JOT.End <!-- [end of repeated rows section] -->
      <tr><td>JOT.Items.TotalPurchase</td></tr>
      </table>
    JOT.End <!-- [end of table IF section] -->

JOT Web Components:

JOT Web Components render dynamic content inside an enclosing JOT Template. The dynamic page is then a composite view rendered with the nested JOT Templates. There is no limit to the nesting depth of JOT Web Components. The following example fills a table cell with a JOT Web Component that uses its own nested JOT Template to render customer information.

    <tr><td>JOT.CustomerInfo</td></tr>

The Content token specifies a JOT Template name for the component. This example renders customer information using a WML template (Wireless Markup Language):

    <tr><td>JOT.CustomerInfo.Content(/webpages/CustomerInfo.wml)</td></tr>

The ShoppingCart JOT Bean in the next example has a CustomerInfo component and a ShoppingCart Items component. These components each render dynamic content with their own JOT Templates inside the enclosing template.

    <hr>
    <!-- Render customer information fields -->
    JOT.ShoppingCart.CustomerInfo
    <p>
    <!-- Render table of selected items -->
    JOT.ShoppingCart.Items
    <hr>
© 2007 JOT Object Technologies