Simon Rydberg wrote:
> Hmmm thanks for a fast reply.
>
> How is that suppose to work?
>
> I have made a little example but I cannot get it to work.
> In jsp-file
> <%
>     Map<String, String> map = new HashMap<String, String>();
>     for (int i = 0; i < 10; i++) {
>         map.put("a", "a" + String.valueOf(i));
>         map.put("b", "a" + String.valueOf(i));
>         map.put("c", "a" + String.valueOf(i));
>     }
>     request.setAttribute("map", map);
> %>
>         <display:table name="map" export="true" pagesize="10000" 
> defaultorder="descending">
>             <display:setProperty name="export.excel.filename" 
> value="test.xls"/>
>             <display:column property="map(a)" title="A*"/>
>             <display:column property="map(b)" title="B*"/>
>             <display:column property="map(c)" title="C*"/>
>
>         </display:table>
>
>
> javax.servlet.jsp.JspException: Error looking up property "map(a)" in object 
> type "java.lang.String". 
That is because your data object is a Map of Strings and not of objects 
containing a getMap() method. It's using the Map as a source of rows 
(each entry =  one row) and then trying to call getMap() on the value of 
the Map entry's value which is, as it tells you, of type java.lang.String.


Create a class:

public class MyMap {
    private Map<String, String> map = new HashMap<String, String>();

    public MyMap(String a, String b, String c) {
       map.put("A", a);
       map.put("B", b);
       map.put("C", c);
    }

    public Map<String, String> getMap() {
       return map;
    }
}


In a jsp file:

<%
    List<MyMap> map = new ArrayList<MyMap>();
    for (int i = 0; i < 10; i++) {
        map.add(new MyMap("a" + i, "b" + i, "c" + i));
    }
    request.setAttribute("map", map);
%>

        <display:table name="map">
            <display:column property="map(A)" title="A*"/>
            <display:column property="map(B)" title="B*"/>
            <display:column property="map(C)" title="C*"/>
        </display:table>

Does that work any better?

Ed!


-------------------------------------------------------------------------
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

Reply via email to