Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=4728314 By: tmoorer
Hi All, I am trying to utilized index properties in a displaytag table, but I'm not sure how to go about it. I have a series of reports to create that are pretty much cookie cutter. The only thing that varies is the column names. What I am trying to do is create a generic "Bean" class that is an array of names and and an array of values. I'm trying to display this in my table like <display:table requestURI="controller" name="sessionScope.searchResults" sort="external" pagesize="<%= Integer.parseInt(recordsPerPage) %>" id="bean" partialList="true" size="sessionScope.resultsSize" class="com.hna.credit.beans.Bean" class="dstg" export="true"> <% String[] columnNames = report.getColumnNames(); String[] columnLabels = report.getColumnLabels(); for (int i=0; i<columnNames.length; i++) { %> <display:column class="dstg" property="<%=((Bean)pageContext.getAttribute("bean")).getName(i)%>" sortable="true"><%=((Bean)pageContext.getAttribute("bean")).getValue(i)%></displ ay:column> <% } %> </display:table> When I try to run this code, I get the following error: Error looking up property "xxx" in object type "com.hna.credit.beans.Bean". which makes me thing that DisplayTag is trying to do the normal property lookup by name, when I'm trying to return the value in the indexed property. Here'e my Bean class if it will help. public class Bean { private String[] names; private String[] values; public Bean(String[] names) { this.names = names; this.values = new String[names.length]; } public String getName(int index) { return names[index]; } public void setValue(int index, String value) { this.values[index] = value; } public String getValue(int index) { return this.values[index]; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("[Bean.java :"); for (int i=0; i<names.length; i++) { if (i>0) { sb.append(","); } sb.append(" "); sb.append(names[i]); sb.append("='"); sb.append(values[i]); sb.append("'"); } sb.append("]"); return sb.toString(); } } ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=249317 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ displaytag-user mailing list displaytag-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/displaytag-user