BBJSP CORE:Iterate Tag (Deprecated)

The BBJSP system is deprecated. For new development, use BBxServlet.

Description

In BBj 16.0 and higher, the iterate tag can be used in a BBJSPBBJSP Page to process each element in the BBjVector specified.

Attributes

Attribute Name

Description

Required

Expression

Data Type

begin

the begin attribute specifies the start point for the iteration. A value if zero (0) indicates the first record

false

true

int

data

the data attribute specifies the BBjVector that contains the records for iteration; this attribute must already exist in the page or session context.

true

true

BBjVector

end

the end attribute specifies the end point for the iteration.

false

true

int

id

the id attribute specifies the name to use for the current element during the looping process; the attribute will be added to the local scope for processing.

true

true

String

index

the index attribute specifies the name of the variable for storing the current index; the index is zero-based.

false

true

int

step

the step attribute specifies the record stepping. For example, a value of 2 will process alternate records. The default is 1.

false

true

int

Remarks

The Core Tag Library library needs to be referenced in the BBJSP Page

The sample page below uses a Scriptlet to add some data to a BBjVector before iterating over the data to display the contents.

Example

<!DOCTYPE html/>

<%-- Import the tag library --%>
<%@ taglib uri='/WEB-CFG/tld/core.tld' prefix='c' %>

<%
REM === Create a BBjVector and put something in it ===
theVect! = new BBjVector() 
theVect!.add("ONE")
theVect!.add("TWO")
theVect!.add("THREE")
theVect!.add("FOUR")
theVect!.add("FIVE")
theVect!.add("SIX")
theVect!.add("SEVEN")
theVect!.add("EIGHT")
theVect!.add("NINE")
theVect!.add("TEN")
REM === Store the Vecor in the page context so we can use it in expressions
#PageContext!.setAttribute("theVector",theVect!)
%>

<html>
<head> 
<title><c:iterate></title> 
</head>
<body>
<br>
<table>
<tr><th width='150px'>ODD</td><th width='150px'>EVEN</td></tr>
<tr>
<td>
<c:iterate data='<%= theVect! %>' id='st' index='ix' step='2' begin='0'>
#${ix} : <c:out value="${st}" /><br>
</c:iterate>
</td>
<td>
<c:iterate data='${theVector}' id='st' index='ix' step='2' begin='1'>
#${ix} : <c:out value="${st}" /><br>
</c:iterate>
</td>
</tr>
</table>
</body>
</html>

See Also

BBJSP

Core Tag Library