aspose file tools*
The moose likes Other Open Source Projects and the fly likes DisplayTag & dynamic pagesize Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "DisplayTag & dynamic pagesize" Watch "DisplayTag & dynamic pagesize" New topic
Author

DisplayTag & dynamic pagesize

Aash Patel
Greenhorn

Joined: Sep 14, 2005
Posts: 24
This is what I have:

<display:table name="sessionScope.results" export="true" defaultorder="descending" pagesize="20">
<display:column property="prop1" title="ID" sortable="true" headerClass="sortable"/>
<display:column property="prop1" title="Description" sortable="true" headerClass="sortable"/>
</display:table>

In my JSP, the user can set paging to true or false which assigns a pagesize variable (in my action class - struts framework) to 0 or 20 respectively. I have successfully implemented this part and also have the pagesize available in the session scope. So I do this:

In JSP:
<%
setdisplaypref = (String) session.getAttribute("setDisplayPref");
request.setAttribute("pagesize", setdisplaypref);
out.println("Display number: " + setdisplaypref);
%>

When I load the JSP, the setdisplaypref variable contains the correct number. I just need to use this variable (setdisplaypref) with the displaytag above. I have tried these:

<display:table name="sessionScope.booksrctyperesults" export="true" defaultorder="descending" pagesize="<%setdisplaypref%>">

<display:table name="sessionScope.booksrctyperesults" export="true" defaultorder="descending" pagesize="<%=setdisplaypref%>">

<display:table name="sessionScope.booksrctyperesults" export="true" defaultorder="descending" pagesize="<%request.getAttribute("pagesize")%>">

Neither of these work - any suggestions?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

The display tag set is not a standardized library. What product does it belong with?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Aash Patel
Greenhorn

Joined: Sep 14, 2005
Posts: 24
This is what I'm using:
http://www.displaytag.org/index.jsp
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

Moved to the Other Open Source Projects forum,
Ram Kankanampati
Greenhorn

Joined: May 26, 2010
Posts: 1
It is very simple. <display> tag pagesize attribute expects a int value rather than String. So you need covert the String value int.

Example:
In your JSP:
<%
String abcdStr = (String)request.getAttribute("abcdStr ");
int abcdInt = Integer.valueOf(abcdStr ).intValue();
%>

<display:table pagesize="<%=abcdInt %>" export="true" cellspacing="1" cellpadding="1" >


Ram.Kankanampati (Cognizant)
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Welcome to Javaranch Ram!


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
veda vyas
Greenhorn

Joined: Apr 11, 2011
Posts: 3
Ram Kankanampati wrote:It is very simple. <display> tag pagesize attribute expects a int value rather than String. So you need covert the String value int.

Example:
In your JSP:
<%
String abcdStr = (String)request.getAttribute("abcdStr ");
int abcdInt = Integer.valueOf(abcdStr ).intValue();
%>

<display:table pagesize="<%=abcdInt %>" export="true" cellspacing="1" cellpadding="1" >



i use above code to set pagesize dynamicall but iam getting below error

ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/KRM].[ActionServlet]] Servlet.service() for servlet ActionServlet threw exception
javax.servlet.jsp.JspException: Can't insert page '/jsp/searchEngine/fileref_search_result.jsp'. Check if it exists.
For input string: "null"
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:908)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:460)
at org.apache.jsp.jsp.template.main_005fbody_jsp._jspx_meth_tiles_get_0(main_005fbody_jsp.java:199)
at org.apache.jsp.jsp.template.main_005fbody_jsp._jspService(main_005fbody_jsp.java:127)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:237)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:300)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
please help me.
Jeff Sanders
Greenhorn

Joined: Mar 28, 2013
Posts: 1
Thanks Ram, the below worked for me.

Jeff

Ram Kankanampati wrote:It is very simple. <display> tag pagesize attribute expects a int value rather than String. So you need covert the String value int.

Example:
In your JSP:
<%
String abcdStr = (String)request.getAttribute("abcdStr ");
int abcdInt = Integer.valueOf(abcdStr ).intValue();
%>

<display:table pagesize="<%=abcdInt %>" export="true" cellspacing="1" cellpadding="1" >

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DisplayTag & dynamic pagesize