Q:
JSTL: Setting value of a tag within a table in a table
I have a list that has an attribute name="person" so its a set of persons (or persons data) that will be shown as a list in a table. There is one more field in the table that I want to populate with the names of each person on each row. This is in the same table but underneath the first person's name. The problem is the table is created dynamically, so I have no clue how to fill out the textArea. Here is the code:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
A:
You could use EL in the td that you want to add value to. Something like this:
|
And if you want to append/prepend a text after the text that is in that particular column.
|
If you don't have access to all the fields in the list you can always get the string index to get your value from the collection.
${persons[item].name}
|
Hope this helps you to achieve what you want.
regards,
Samir
A:
I don't believe it's possible to do this by directly rendering the elements. You'll need to render a JSP tag to put the row-specific value into the cell.
But you could also just render another table inside the loop.
If this isn't a possibility for you, it sounds like a perfect use case for a JSF
.
...
...
...
Or you can use a standard JSP and simply render all the rows as links.