I'm in a struts/tiles world and having some difficulty doing this in reusable fashion.... I have a List of rows that contain cells/columns. I want to iterate over the rows and then iterate over the cells and get a value from the row's cell. Different tables all have rows, but the cells and the getters for those cells are different for each table. How can I generically get the the cell's value (which is stored in the row). To help myself out I get to define the List of cells.
Inside the row loop I loop over columns (using the id column) and I can use an expression to specify the property of the row that I want: <bean:write name="row" property="<%= column %>" /> that works just fine. The draw back being that I am defining the ArrayList (that "map" the this particular tables columns) in the jsp that I want to generically iterate. I would have to repeat the looping code for each table, that would be bad.
What I think I would prefer (I'm open to alternatives), is to define the columns in a a putList (that I have named columnNames) in the tiles insert that defines the rest of the page. This makes sense to me. And it does in pass my list to the appropriate JSP. But the problem is that I can't use the putList values in the bean:write tag.
<bean:write name="columnName"/> <%-- this works - and outputs the column name, but not the value of in the column of the in the row with that name --%>
I have tried several variations to no avail. Any help would be greatly appreciated. I have posted the full source of the jsp with the loop as well as the source of the jsp doing the tiles insert below. Not posted is the layout page that has one contributing tag:
Also it's worth noting that inside the row loop I loop over the ArrayList of columns and then within that I loop over the putList columns. This is only for convenience while testing and switching back and forth, obviously it will be one or the other looping over the columns just once (preferable the putList).
This is what I came up with. It still uses scriplets, but it does allow me to use a putList (which defines the rows _where_ I want - in the first/top tile jsp) to get values out of another object that is being looped upon. Now the code can be reused by any table/grid.
When a Sherrif, Bartender or other administrator indicates in a thread that he/she is sending a private message to an individual, you can be certain that it is not private information about the topic, but rather some administrative detail such as compliance with the naming policy and other matters of conern only to the individual, and not to the forum at large.