jsp+displaytag

Hi all,

I am using displaytag to view my data and here am using export="true" in display:table.. Am using group="1" in display:column...

When i view the output am getting total and subtotal correctly.. but when i view this with excel or pdt am not getting total column.. Can anyone help me out where i have gone wrong.. Thanks in advance...

Here is my code:

<display:table name="sessionScope.results.rows" class="reportviewer" export="true" id="row" defaultsort="1" defaultorder="ascending"

pagesize="40" cellspacing="0" decorator="org.displaytag.decorator.TotalTableDecorator" >

<display:setProperty name="paging.banner.placement" value="top" />

<c:forEach var="obj" items="${col}">

<c:choose>

<c:when test='${obj== "Date"}'>

<display:column property="${obj}" sortable="true" group="1"/>

</c:when>

<c:when test='${obj== "CTR"}'>

<display:column property="${obj}" sortable="true" total="true"/>

</c:when>

<c:when test='${obj== "Impressions"}'>

<display:column property="${obj}" sortable="true" total="true"/>

</c:when>

<c:when test='${obj== "Clicks"}'>

<display:column property="${obj}" sortable="true" total="true"/>

</c:when>

<c:otherwise>

<display:column property="${obj}" sortable="true"/>

</c:otherwise>

</c:choose>

</c:forEach>

</display:table>

[1559 byte] By [shruthi04a] at [2007-10-3 1:19:03]
# 1
Can anyone help me out
shruthi04a at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hello can anyone help me out...
shruthi04a at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Please ese the code button above the posting area to format code in your posting. Read [url http://forum.java.sun.com/help.jspa?sec=formatting]formatting tips[/url].

With regards your question,

<display:table name="sessionScope.results.rows" ....

should be

><display:table name="${sessionScope.results.rows}" ....

What do you mean when you say

[quote]

When i view the output am getting total and subtotal correctly.. but when i view this with excel or pdt am not getting total column

[/unquote]

You are trying to open an html using excel?

ram.>

Madathil_Prasada at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Hi thanks for your reply..I am exporting data to excel from display tag report.. In Displaytag report am getting total column but when i export it to excel or pdf its not showing total column...Can u please help me out
shruthi04a at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

This my code

<display:table name="sessionScope.results.rows" class="reportviewer" export="true" id="row" defaultsort="1" defaultorder="ascending"

pagesize="40" cellspacing="0" decorator="org.displaytag.decorator.TotalTableDecorator" >

<display:setProperty name="paging.banner.placement" value="top" />

<c:forEach var="obj" items="${col}">

<c:choose>

<c:when test='${obj== "Date"}'>

<display:column property="${obj}" sortable="true" group="1"/>

</c:when>

<c:when test='${obj== "CTR"}'>

<display:column property="${obj}" sortable="true" total="true"/>

</c:when>

<c:when test='${obj== "Impressions"}'>

<display:column property="${obj}" sortable="true" total="true"/>

</c:when>

<c:when test='${obj== "Clicks"}'>

<display:column property="${obj}" sortable="true" total="true"/>

</c:when>

<c:otherwise>

<display:column property="${obj}" sortable="true"/>

</c:otherwise>

</c:choose>

</c:forEach>

</display:table>

shruthi04a at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Hello anyone can suggest me some idea
shruthi04a at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

From what I can gather on googling, this functionality isnt supported. The column decorators for totalling (TotalTableDecorator) works only for the web (ie html) view.

Look at the issue mentioned [url http://jira.codehaus.org/browse/DISPL-298] here [/url] and [url http://jira.codehaus.org/browse/DISPL-301]here[/url].

I think you'll find more help at the source forge forums than here :).

ram.

Madathil_Prasada at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

Some more info - you can write your own ExcelDecorator. There is a sample implementation in the source code.

Go to source forge - download the source code -unzip it and go to

\displaytag-1.1\displaytag-examples\src\main\java\org\displaytag\sample\decorators

You'll find a class called HssfTotalWrapper that shows you how to do it. Its non-trivial and you'll have to learn the display tag apis and also have the apache poi-hssf jars (which are used behind the screens to create the excel jar files) in your classpath and WEB-INF/lib.

ram.

Madathil_Prasada at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Hi Ram thanks alot.. I went through Sourge forum, but no one to reply.. But ur reply would help me alot.. Thanks for ur helpThanks once againShruthi
shruthi04a at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

Madathil_Prasad is correct. You will need to write your own Excel, PDF,RTF, CSV decorator. On the displaytag page take a look at the WYSIWYG Exporting...this is what you want to achieve. Only problem on that page is that there isn't a lot of code examples on how to implement these new / different decorators.

Soooo...check out this page....

http://www.jamesgood.com:8080/displaytag-examples-1.1-SNAPSHOT/example-new-export.jsp

At there bottom there are links to actual code to how he did the export. Prretty cool, and if you implement it correctly, it is pretty reusable.

--Nick

NIck_Larsona at 2007-7-14 18:16:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...