• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

DisplayTag & dynamic pagesize

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • 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?
 
Marshal
Posts: 67357
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
This is what I'm using:
http://www.displaytag.org/index.jsp
 
Bear Bibeault
Marshal
Posts: 67357
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Other Open Source Projects forum,
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch Ram!
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
  • 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" >

 
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!