Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulate tr id tag using jstl
    primarykey
    data
    text
    <p>I'm trying to retrieve a table from a database and populating it in a table. The table will be editable by using EditableGrid (<a href="http://www.editablegrid.net/en" rel="nofollow">http://www.editablegrid.net/en</a>). I'm populating the tables automatically like so:</p> <h1>Report Results</h1> <pre><code>&lt;table id="htmlgrid" border="1"&gt; &lt;!-- column headers --&gt; &lt;tr&gt; &lt;c:forEach var="columnName" items="${result.columnNames}"&gt; &lt;th&gt;&lt;c:out value="${columnName}" /&gt;&lt;/th&gt; &lt;/c:forEach&gt; &lt;/tr&gt; &lt;!-- column data --&gt; &lt;c:forEach var="row" items="${result.rowsByIndex}"&gt; &lt;tr&gt; &lt;c:forEach var="column" items="${row}"&gt; &lt;td&gt;&lt;c:out value="${column}" /&gt;&lt;/td&gt; &lt;/c:forEach&gt; &lt;/tr&gt; &lt;/c:forEach&gt; &lt;/table&gt; </code></pre> <p>The result is retrieved like so:</p> <pre><code>c = ConnectionManager.getConnection(); ps = c.prepareStatement("select * from test_persons", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = ps.executeQuery(); Result result = ResultSupport.toResult(rs); request.setAttribute("result", result); RequestDispatcher rd = request .getRequestDispatcher("/display.jsp"); rd.forward(request, response); </code></pre> <p>The thing is, in order to use EditableGrid, the tr tags need an id, for example:</p> <pre><code> &lt;tr id="R1"&gt; &lt;td&gt;Duke&lt;/td&gt; &lt;td&gt;Patience&lt;/td&gt; &lt;td&gt;33&lt;/td&gt; &lt;td&gt;1.842&lt;/td&gt; &lt;td&gt;uk&lt;/td&gt; &lt;td&gt;patience.duke@gmail.com&lt;/td&gt; &lt;td&gt;false&lt;/td&gt; &lt;td&gt;11/12/2002&lt;/td&gt; &lt;/tr&gt; &lt;tr id="R2"&gt; &lt;td&gt;Rogers&lt;/td&gt; &lt;td&gt;Denise&lt;/td&gt; &lt;td&gt;59&lt;/td&gt; &lt;td&gt;1.627&lt;/td&gt; &lt;td&gt;us&lt;/td&gt; &lt;td&gt;rogers.d@gmail.com&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;07/05/2003&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>How would I use the jstl to automatically put in the tags in? The database may return any number of rows depending on the query. Is this possible? Or is there a better solution to populate a table from a resultset and make it editable (for the purposes of updating the database later on).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload