Samples

SamplesXml

Code

Config

API Docs

Download

Neolectric

Loops

Lets get a set of records to print. This will create a row, col matrix of Strings.

<dxp:DbAction value="query" dbcon="demo" store="bids">
 <dxp:Cp name="stmt">select id, email, item, biddate, amount from auction</dxp:Cp>
</dxp:DbAction>

Print all rows of the matrix and specify how each col should be displayed

<table border="0">
 <dxp:LoopMatrix value="${bids}" cols="0,1,2,3,4"> <!-- store col values -->
 <tr bgcolor="#ccccff">
  <td>${0}</td>
  <td>${1}</td>
  <td>${2}</td>
  <td align="right">${3}</td>
  <td align="right">${4}</td>
 </tr>
 </dxp:LoopMatrix>
</table>
1 mark@coldmail.com Eternal Battery 07/01/01 10.00
2 mark@coldmail.com Startup.com Stock 07/01/01 5.00
3 mark@coldmail.com Herbal Youth Tonic 07/10/01 20.00
4 johndoe@msn.not Eternal Battery 07/12/01 20.00
5 karl@youhoo.com Eternal Battery 07/17/01 100.00
6 mark@coldmail.com Super WhamoBots 10/02/01 8.00
7 rx8re3x@spambot.net Startup.com Stock 01/13/02 32.00
8 japerry@jademicrosystems.com Super WhamoBots 08/29/02 56.00

Pass each row to a LoopArray and tell it to print all cols

<table border="0">
 <dxp:LoopMatrix value="${bids}" cols="row"> <!-- store array of values -->
 <tr bgcolor="#ccffcc">
  <dxp:LoopArray value="${row}" cols="n"><td>${n}</td></dxp:LoopArray>
 </tr>
 </dxp:LoopMatrix>
</table> 
1mark@coldmail.comEternal Battery07/01/0110.00
2mark@coldmail.comStartup.com Stock07/01/015.00
3mark@coldmail.comHerbal Youth Tonic07/10/0120.00
4johndoe@msn.notEternal Battery07/12/0120.00
5karl@youhoo.comEternal Battery07/17/01100.00
6mark@coldmail.comSuper WhamoBots10/02/018.00
7rx8re3x@spambot.netStartup.com Stock01/13/0232.00
8japerry@jademicrosystems.comSuper WhamoBots08/29/0256.00

Note: this loses the ability to customize the display format of each col separately.
The Date and Amount cols are now left aligned just like the rest of the cols.

Printing a subset of rows - offset is the row index to start at, count is the nuber to print

<table border="0">
 <dxp:LoopMatrix value="${bids}" cols="0,1,2,3,4" offset="3" count="2">
 <tr bgcolor="#ffcccc">
  <td>${0}</td>
  <td>${1}</td>
  <td>${2}</td>
  <td align="right">${3}</td>
  <td align="right">${4}</td>
 </tr>
 </dxp:LoopMatrix>
</table>
4 johndoe@msn.not Eternal Battery 07/12/01 20.00
5 karl@youhoo.com Eternal Battery 07/17/01 100.00

Note: offset represents the row index which is 1 less than the row number displayed.
dxp follows the C,C++,Java convention for array indexes and begins them at 0, not 1.