Skip to content

Instantly share code, notes, and snippets.

@aakash14goplani
Last active June 26, 2017 09:07
Show Gist options
  • Save aakash14goplani/6464195e4dd22d8fb4e2bb73fd00b0da to your computer and use it in GitHub Desktop.
Save aakash14goplani/6464195e4dd22d8fb4e2bb73fd00b0da to your computer and use it in GitHub Desktop.
List Loop

To loop a list we make use of listloop tag

JAVA

IList list = ics.GetList("list_name");
int rows = list.numRows();
int cols = list.numColumns();
String columnName = "", columnValue = "";
out.println("Rows : " + rows + ", " + "Columns : " + cols + " for list " + list.getName() + " : " + list.hasData() + "<br/>");
for(int i=1; i<=rows; i++){
  for(int j=0; j<cols; j++){
    out.println("Is " + list.currentRow() + " last row : " + list.atEnd() + "<br/>");
    columnName = list.getColumnName(j);
    columnValue = list.getValue(columnName);
    out.println(columnName + " : " + columnValue + "<br/>");
    list.moveTo(i+1);
  }
}

JSP

<ics:listloop listname="titleList">
  <ics:listget fieldname="value" listname="titleList"/><br/>
  <ics:listget fieldname="#curRow" listname="titleList"/><br/> // returns current row number
  <ics:listget fieldname="#numCols" listname="titleList"/><br/> // returns total number of columns
  <ics:listget fieldname="#numRows" listname="titleList"/><br/> // return total number of rows
</ics:listloop>

XML

<LOOP [FROM="START"] [COUNT="LOOP_TIMES"] LIST="abc" [UNTIL="END"]>
  <ICS.LISTGET LISTNAME="abc" FIELDNAME="value" OUTPUT="some_value" />
</LOOP>
#numRows
Number of rows in this list
#curRow
Current row in this list.
#moreRows
Boolean (true/false) to indicate whether there are more rows following the current row.
#numCols
Number of columns in this list.
@<colname>
Only used on lists that contain resultsets. Contents of the file in the specified column if the colname begins with "url".

Documentation

LOOP
ICS.LISTGET
ics:listloop
ics:listget TomRed Blog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment