tags:

views:

4061

answers:

3

Hello All,

I am using Displaytag framework for pagination & exporting purpose. In that i am also using Strut2Tiles Integration.

Whenever i am calling any action class it will returning me a list & through Displaytag i am successfully displaying record on my page. For that my jsp page's code looks like :

  <s:set name="selectedPageSize" value="selectedPageSize" scope="request"/>
        <s:set value="accountList" scope="request" name="accountList"/>
            <display:table name="accountList" export="true" class="table" requestURI="" id="accountList" pagesize="${selectedPageSize}" >
            <display:setProperty name="export.pdf" value="true" /> 
            <display:column property="id" sortable="true" class="sort-title"/>
            <display:column property="name" sortable="true"/>
            <display:column property="contactPerson" sortable="true"/>
            <display:column property="phone1" sortable="true"/>
            <display:column property="phone2" sortable="true"/>
            <display:column property="fax" sortable="true"/>
            <display:column property="email" sortable="true"/>
            <display:column property="webSite" sortable="true"/>
            <display:column property="address1" sortable="true"/>
            <display:column property="address2" sortable="true"/>
            <display:column property="countryId.name" title="Country" sortable="true"/>
            <display:column property="stateId.name" title="State" sortable="true"/>
            <display:column property="countryId.name" title="City" sortable="true"/>

            <display:column property="isDeleted" sortable="true"/>

            <display:column title="Delete">
                <s:url id="removeUrl" action="finance/deleteAccount.action">
                    <s:param name="id" value="#attr.accountList.id" />
                </s:url>
                <s:a href="%{removeUrl}" theme="ajax" targets="accountList">Remove</s:a>
            </display:column>

            <display:column  title="Update">
                <s:url id="updateUrl" action="finance/updateAccount.action">
                    <s:param  value="#attr.accountList.id" name="id"/>
                </s:url>
                <s:a href="%{updateUrl}&action=update" targets="accountlist">Update</s:a>
            </display:column>

Actually this page is displaying through tiles configuration.

Here i have enabled the export option, so it is showing me the exporting options like CSV, EXCEL, XML. But whenver i am clicking on that CSV link, my web browser hanged, means nothing is displayed on it

For that exporting solution i have also added filter in my web.xml. My web.xml looks like:

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
  <filter>
    <filter-name>ResponseOverrideFilter</filter-name>
    <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
</filter-mapping>

<listener>
    <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/webApplicationContext.xml</param-value>
</context-param>

<welcome-file-list>
    <welcome-file>jsp/welcome.jsp</welcome-file>
</welcome-file-list>

I have also included following list of libraries of displaytag : 1) displaytag-1.2.jar 2) displaytag-export-poi-1.2.jar 3) displaytag-portlet-1.2.jar

The exception that i am getting is :

2009-05-09 12:02:38,234 DEBUG (org.displaytag.tags.TableTag:1524) - Exportfilter NOT enabled
2009-05-09 12:02:38,312  WARN (org.displaytag.tags.TableTag:63) - Exception: [.TableTag] Unable to reset response before returning exported data. You are not using an export filter. Be sure that no other jsp tags are used before display:table or refer to the displaytag documentation on how to configure the export filter (requires j2ee 1.3).
ApplicationDispatcher[/PaginationTry2] PWC1231: Servlet.service() for servlet jsp threw exception
Exception: [.TableTag] Unable to reset response before returning exported data. You are not using an export filter. Be sure that no other jsp tags are used before display:table or refer to the displaytag documentation on how to configure the export filter (requires j2ee 1.3).

Plz reply, i am stuck with this problem.

+1  A: 

Have you tried re-ordering the filters in your web.xml so that DisplayTag's ResponseOverrideFilter is the first filter in the chain, i.e. before your struts2 filter?

A_M
A: 

Configure your displaytag table :

<display:table name="sessionScope.searchProviderLRSharingList"
id="row"
requestURI="/**ACTION_MAPPING_CALLED_TO_GET_THE_RESULTS**"
...
...
</display:table>

Configure the Filter in your web.xml:

<filter>
    <filter-name>ResponseOverrideFilter</filter-name>
    <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>

ResponseOverrideFilter ACTION_MAPPING_CALLED_TO_GET_THE_RESULTS

Muhammad Shahid
A: 

Thanks for your solution...I got it

phani