I have a tagx to create a table with head <th>...</th>
, based on the table.tagx by/of Spring Roo.
To get text into the head colums is easy, but when it comes to titles, I'm stuck.
This is my current way to fill the table head:
<spring:eval var="colCounter" expression="0" />
<table id="_table_${id}_id" class="sortable" >
<thead>
<tr>
<c:forTokens items="${columnLabels}" delims="," var="columnHeading">
<th>
<c:out value="${columnHeading}" />
<spring:eval var="colCounter" expression="colCounter + 1" />
</th>
</c:forTokens>
[... some more unimportant code here ...]
</tr>
</thead>
<tbody>
...
</tbody>
</table>
columnLabels
is a comma separed string containing the the labels. I generated another string called columnTitles
, which is built just the same way.
So what I'd like to do now, is to add the titles for each column into the <th>
tag like
<th title="${columnTitle}" >
I could probably loop through an array with the colCounter
as index like this
<th title="${columnTitles[colCounter]}" >
But this would mean some more effort since I'd need to create the array in a completely different way - plus, I'm not very familiar with tagx/jstl (yet).
I still hope, somebody has a solution. I'd be very glad!
Regards, Stacky
Forget about having two separate comma-separated strings.
Use a List<Heading>
, where Heading
is a bean containing a title
property and a tooltip
property.
Your JSP code is now straightforward, and doesn't need to parse a comma-seperated String into a list of tokens:
<c:forEach items="${headings}" var="heading">
<th title="<c:out value='${heading.tooltip}'/>">
<c:out value="${heading.title}" />
</th>
</c:forEach>
Java is an OO language. Use objects.