Raajkumar wrote:
> I was trying to find the solution for the problem I had, but could not find
> it ... So I am posting it... 
>
> I have List of beans say 
>
> product 
>    - String name
>    - int id
>    - List years (which is a list of beans year)
>
> year
>   - String name
>   - long amount
>
> The problem is, the list years is different for different product... 
>   
This seems to be the problem of the month. What you are wanting is to 
pivot your data from three dimensions into two dimensions and really I 
don't think displaytag can do this for you.

What you can do is create a List and store in it a Map of values:

So this:
Product:
    name = boat
    id = 5
    List year
       2007, 5
       2009, 8
       2010, 2
       2154, 1

becomes
Map:
    name = boat
    id = 5
    2007 = 5
    2009 = 8
    2010 = 2
    2154 = 1

Now displaytag can handle your data. Also while you're transforming your 
data you can keep a track of the years that any of your products contain 
which you can use to generate <display:column> tags:

<display:table name="mylistofmaps">
    <display:column property="name"/>
    <display:column property="id"/>
    <c:forEach items="${years}" var="year">
       <display:column property="${year}"/>
    </c:forEach>
</display:table>

As I've said before it's called DISPLAYtag. It is excellent at 
displaying data and tries its best at other things but it is not some 
panacea that can magically transform your arbitrary data into a table 
without you doing some work.

Hope I've helped.

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