• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

DisplayTag & dynamic pagesize

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The display tag set is not a standardized library. What product does it belong with?
 
Aash Patel
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I'm using:
http://www.displaytag.org/index.jsp
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the Other Open Source Projects forum,
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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" >

 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Javaranch Ram!
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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" >

 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic