Displaytag struts 2 go to specific page

我的未来我决定 提交于 2019-11-28 06:36:33

问题


in my project i'm using display tag. The problem comes when the results returned are like e.g. 300 pages. The user needs to jump to page e.g. 200 but he can't. He needs to go slowly there ( 5 pages at a time or so ). I want to add the ability to the user to choose in a drop-down the page he wants to jump to. Is there any property in display-tag or any suggestion?


回答1:


You need to use ParamEncoder to get the name (and eventually the value) of displayTag's parameters, specified in TableTagParameters.html, in your case PARAMETER_PAGE.

<div>
    With Scriptlets 
    <br/>
    <% String pageNumParameter = 
              new org.displaytag.util.ParamEncoder("id_of_your_displaytag_table").encodeParameterName(org.displaytag.tags.TableTagParameters.PARAMETER_PAGE); %>
    [parameter name] = <%= pageNumParameter %>
    <br/>
    [parameter value]= <%= request.getParameter(pageNumParameter) %> 
</div>

<div>
    With OGNL
    <br/>   
    <s:set var="pageNumParameter" 
           value="%{new org.displaytag.util.ParamEncoder('id_of_your_displaytag_table').encodeParameterName(@org.displaytag.tags.TableTagParameters@PARAMETER_PAGE)}" />        
    [parameter name] = <s:property value="%{#pageNumParameter}"/>
    <br/>
    [parameter value]= <s:property value="#parameters[#pageNumParameter]"/>
</div>

Then you should be able to craft a request by passing the dynamic generated parameter for that table, with the value you want (from a SelectBox, from an Input Text, from a script etc)



来源:https://stackoverflow.com/questions/16188819/displaytag-struts-2-go-to-specific-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!