Doing a generic <sql:query> in Grails
- by melling
This is a generic way to select data from a table and show the results in an HTML table using JSP taglibs.  What is the generic way to do this in Grails?  That is, take a few lines of SQL and generate an HTML table from scratch in Grails, including the column names as headers.
<sql:query var="results" dataSource="${dsource}"
    select * from foo
</sql:query
(# of rows: ${results.rowCount})
<table border="1"
    <!-- column headers --
    <tr bgcolor=cyan
        <c:forEach var="columnName" items="${results.columnNames}"
            <th<c:out value="${columnName}"/</th
        </c:forEach
    </tr
    <!-- column data --
    <c:forEach var="row" items="${results.rowsByIndex}"
        <tr
            <c:forEach var="column" items="${row}"
                <td<c:out value="${column}"/</td
            </c:forEach
        </tr
    </c:forEach
</table
The solution to this was answered in another StackOverFlow question.
http://stackoverflow.com/questions/425294/sql-database-views-in-grails
IF SOMEONE WRITES A GOOD ANSWER, I'LL ACCEPT IT.  I would like a 100% acceptance on all of my questions.