Home > Contents > Index >
ics:listloop
Iterates a list.
Syntax
<ics:listloop listname="some list" [maxrows="number of loops"] [startrow="start row"] [endrow
="end row"]> </ics:listloop>Parameters
listname (required)
- Name of the list to iterate.
maxrows (optional)
- Maximum iterations the loop should be executed. If
maxrows
is omitted, the loop iterates to the end of list.
startrow (optional)
- Row number to start the iteration. If omitted,
ics:listloop
begins iterating from the current row. This attribute cannot take zero or a negative values.
endrow (optional)
- Row number of the row to end the iteration. If omitted or if given a value of -1, the iteration continues to the end of list.
Error Numbers
There are no possible
errno
for this tag.Example
<ics:sql sql="Select * from SystemInfo" listname="mylist" table="SystemInfo" limit="20"/> <ics:listloop listname="mylist"> <ics:listget listname="mylist" fieldname="tblname" /> </ics:listloop>The above code simply iterates through and prints all the 20 rows of the SystemInfo table that were retrieved by the ics:sql tag.
<ics:sql sql="Select * from SystemInfo" listname="mylist" table="SystemInfo" limit="20"/> <ics:listloop listname="mylist" endrow="10"> <ics:listget listname="mylist" fieldname="tblname" /> </ics:listloop>This code prints only the first 9 rows of the SystemInfo table because the endrow is specified to be 10.
Looping stops when the current row number becomes equal to endrow and hence the 10th row does not get printed.
<ics:sql sql="Select * from SystemInfo" listname="mylist" table="SystemInfo" limit="20"/> <ics:listloop listname="mylist" startrow="3" endrow="10"> <ics:listget listname="mylist" fieldname="tblname" /> </ics:listloop>This code prints the rows from 3 to 9, because we specify to start from row 3 using the startrow attribute. This attribute CANNOT be zero or negative. When startrow is equal to endrow, no rows will be output.<ics:sql sql="Select * from SystemInfo" listname="mylist" table="SystemInfo" limit="20"/> <ics:listloop listname="mylist" maxrows="10"> <ics:listget listname="mylist" fieldname="tblname" /> </ics:listloop>This code uses maxrows attribute and prints out the first 10 rows of the SystemInfo table.
Unlike endrow, the maxrows attribute causes the looping to proceed until the current row number becomes greater than that specified in the maxrows attribute.<ics:sql sql="Select * from SystemInfo" listname="mylist" table="SystemInfo" limit="20"/> <ics:listloop listname="mylist" maxrows="10" endrow="10"> <ics:listget listname="mylist" fieldname="tblname" /> </ics:listloop>Finally, when we use both endrow and maxrows, the endrow attribute takes preference and looping is stopped when the current row number equals the endrow attribute. Hence, the final code snippet will only print 9 rows, even though the maxrows attribute specifies the value 10.See Also
Home > Contents > Index > ![]()
Oracle JSP Tag Reference
Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.