Forums Register Login

DisplayTag & dynamic pagesize

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
The display tag set is not a standardized library. What product does it belong with?
+Pie Number of slices to send: Send
This is what I'm using:
http://www.displaytag.org/index.jsp
+Pie Number of slices to send: Send
Moved to the Other Open Source Projects forum,
+Pie Number of slices to send: Send
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" >

+Pie Number of slices to send: Send
Welcome to Javaranch Ram!
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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" >

 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 11112 times.
Similar Threads
Pagination in Struts2
Dynamic Attribute assignment (in Struts)
problem with display tag
Best way to make sortable columns?
display tag export problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:23:20.