Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
785 views
in Technique[技术] by (71.8m points)

jsp - Displaytag struts 2 go to specific page

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...