Hi.

I need help to solve this problem: I have a table in my database with a lot
of rows and i'm using hibernate, struts2, spring  and displaytag to get the
information and show it to the user. Because i have lots of records i tried
to implement pagination using hibernate (setting maxResults and
firstResult).

My question is, how can i get all the records to export? At this moment i
only export the data shown in the page and what i wanna is to export
everything.

Here's my code:

-----------------------------software.jsp ------------------------------
<%@ include file="/WEB-INF/common/Taglibs.jsp"%>
<%@ taglib uri="http://displaytag.sf.net"; prefix="display"%> 

<jsp:directive.page contentType="text/html; charset=UTF-8" />

<!-- Main Content -->
<div class="mainContent">

        <s:form method="post" action="listSW" >
                <div>
                        <display:table id="softwareTable" name="softwareList" 
class="dataTable"
export="true" pagesize="10" requestURI="listSW_findAllSoftware.action"
sort="list" defaultorder="ascending" partialList="true" size="${resultSize}"
defaultsort="1">
                                <display:column property="id" title="Id" 
sortable="true"
headerClass="sortable" />
                                <display:column property="swType" title="Type" 
sortable="true"
headerClass="sortable"/>
                                <display:column property="swVersion" 
title="Version" sortable="true"
headerClass="sortable"/>
                        </display:table>
                </div>
        </s:form>
</div>

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

-----------------------DisplayTag.properties-----------------------
#sort.amount=list
paging.banner.placement=top
#paging.banner.all_items_found=
paging.banner.some_items_found=Total {0} {1} found, displaying {2} to {3}.
#paging.banner.one_item_found=
#paging.banner.onepage=
paging.banner.full=<div class="pagelinks" align="right"> {1} 
images/first.gif   {2}  images/prev.gif  {0} {3}  images/next.gif   {4} 
images/last.gif  </div>
paging.banner.first=<div class="pagelinks" align="right"> {1} 
images/first.gif   {2}  images/prev.gif   {0}  {3}  images/next.gif   {4} 
images/last.gif  </div>
paging.banner.last=<div class="pagelinks" align="right"> {1} 
images/first.gif   {2}  images/prev.gif   {0}  {3}  images/next.gif   {4} 
images/last.gif  </div>

export.banner=<div class="pagelinks" align="right">{0}</div>
#export.amount=list
#export.decorated=true

export.types=csv excel xml pdf

export.csv.class=org.displaytag.export.CsvView
export.excel.class=org.displaytag.export.ExcelView
export.xml.class=org.displaytag.export.XmlView
export.pdf.class=org.displaytag.export.PdfView

export.csv=true
#export.csv.label=CSV 
export.csv.include_header=true
export.csv.filename=data.csv
export.csv.export_amount=list

export.excel=true
#export.excel.label=Excel 
export.excel.include_header=true
export.excel.filename=data.xls
export.excel.export_amount=list

export.xml=true
#export.xml.label=XML 
export.xml.filename=data.xml
export.xml.export_amount=list

export.pdf=true
#export.pdf.label=PDF 
export.pdf.include_header=true
export.pdf.filename=data.pdf
export.pdf.export_amount=list


-------------------------------------------------------------------------


------------------------------SoftwareAction.java---------------------------------
public String findAllSoftware(){
                
                String opcao = "LISTSW";
                
                try {
                        
                        String acesso =
userService.validaOpcao(this.getSession().get("userSession"), opcao);
                        
                        if(acesso.equals("UserOk")){
                                System.out.println("entrou no input");
                                LOG.info("[SoftwareTableAction] -> 
listAllSoftware()");
                                
                                //Number of elements for each page
                        this.setPageSize(10);
                        
                                //get the page number from request
                        this.setActualPage(getPage(this.getServletRequest()));
                        System.out.println("---> PAGE :" + 
this.getActualPage());
                            
                       
                                
                        
this.setSoftwareList(softwareTableService.findAllSoftware(this.getActualPage(),
this.getPageSize()));
                                
this.setList(softwareTableService.completeList());
                                
                                
                                
                                
this.setResultSize(softwareTableService.countResults());
                                System.out.println("RESULT SIZE : " + 
this.resultSize);
                                
                                servletRequest.setAttribute("softwareList", 
this.getSoftwareList());
                                
servletRequest.setAttribute("resultSize",this.getResultSize());
                                servletRequest.setAttribute("pageSize", 
this.getPageSize());
                                servletRequest.setAttribute("list", 
this.getList());
                                return SUCCESS;
                                
                        }
                        else{
                                this.addActionError(acesso);
                                return "accessDenied";
                        }
                } catch (RemoteException e) {
                        e.printStackTrace();
                        LOG.error("[ClientInfoAction] -> insertClientInfo(): " 
+ e.toString());
                        this.addActionError("Exception occured during the 
execution of a remote
method call");
                        return INPUT;
                }
        }
        
        

        public int getPage(HttpServletRequest request){
                
                System.out.println("GET PAGE:");
              int page = 0;
                Enumeration paramNames = request.getParameterNames();
                while (paramNames.hasMoreElements()) {
                    String name = (String)paramNames.nextElement();
                    System.out.println("NAME: " + name);
                    if (name != null && name.startsWith("d-") &&
name.endsWith("-p")) {
                        String pageValue = request.getParameter(name);
                        System.out.println("PAGE VALUE: " + pageValue);
                        if (!pageValue.equals("")) {
                                System.out.println("PAGE VALUE != NULL");
                            page = Integer.parseInt(pageValue)-1;
                            System.out.println("PAGE: " + page);
                        }
                        else{
                                System.out.println("ENTROU NO ELSE. O VALOR DA 
PAGINA
ACTUAL É: " + this.getActualPage());
                                return page=this.getActualPage();
                        }
                                
                    }
                }
                System.out.println("RETURN PAGE: " + page);
                return page;
            }
-------------------------------------------------------------------------


------------------------------SoftwareServiceImpl.java---------------------------------
public List findAllSoftware(int actualPage, int pageSize) {
                return softwareTableDAO.findAllSoftware(actualPage, pageSize);
        }
        
        public int countResults(){
                return softwareTableDAO.countResults();
        }
-------------------------------------------------------------------------

------------------------------SoftwareDAOHibernate.java---------------------------------
public List findAllSoftware(int page, int pageSize){
                String q = "from SoftwareTable as softwareTable";
                Query query = this.getSession().createQuery(q);
                query.setMaxResults(pageSize);
                query.setFirstResult(page * pageSize);
                return query.list();
        }
        
        public int countResults(){
                String q = "from SoftwareTable as softwareTable";
                Query query = this.getSession().createQuery(q);
                return query.list().size();
        }
---------------------------------------------------------------------------------



-- 
View this message in context: 
http://www.nabble.com/DisplayTag---Exporting-all-data-tp17827132p17827132.html
Sent from the DisplayTag - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to