Hi!
I want to display columns that does not exist as properties in a class. Instead
I have stored the data in a map.
Let’s say I have the following data that I want to display:
key col value
a1 b1 2
a2 b1 3
a2 b2 6
a3 b2 2
a3 b1 5
a4 b3 5
.. ..
a2000 b3 1
a2000 b20 3
So the a values range from 1- to ??? ( in the example 2000 ) and the b values
range from 1-??? ( in the example 20 ).
I want to display the b values as columns with so the example will be:
key b1 b2 b3
... b20
a1 2
a2 3 6
a3 5 2
a4
5
...
a2000 1
3
So adding a new b-value in the datatable would lead to adding a column in the
displaytag table.
My class storing the data would be something like this:
class DataHolder{
private String key; // the unique a-value
private Map<String, Integer> map; //containing all
the b values for the key.
public String getKey(){
return key;
}
public void setKey(String key){
this.key = key;
}
public String getMapValue(String col){
Integer value =
map.get(col);
return value;
}
public Map getMap(){
return map;
}
public void setMap(Map map){
this.map = map;
}
public List getColumns(){
List retList = new ArrayList();
Object keys[] = map.keySet().toArray();
for (int i = 0; i < keys.length; i++) {
Object o = map.get(keys[i]);
retList.add(o);
}
return retList;
}
}
Ok, so using this class I want to create the outputtable in displaytag.. how
can I do this?
As of my understanding I can only display properties that exist in the class.
In my example the property key, via the
<%
List datas = BusinessFacade.getClassDatas(); // returning a list of all the
ClassData's...
request.setAttribute("datas", datas);
%>
<display:table name="datas" export="false" sort="list" pagesize="10000"
defaultorder="descending">
<display:column property="key" title="Key"
sortable="true" headerClass="sortable"/>
<!--how to display the columns here???-->
</display:table>
/Simon
-------------------------------------------------------------------------
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