Displaytag struts 2 go to specific page

in my project I use a display tag. The problem occurs when the returned results are, for example, 300 pages. The user must go to the page, for example. 200, but he cannot. He needs to go there slowly (5 pages at a time). I want to add the ability for the user to select the page that he wants to go to from the drop-down list. Is there a property in the display-tag or some suggestion?

+1
source share
1 answer

You need to use ParamEncoder to get the name (and finally the value ) of the parameters displayTagspecified 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 can create requestby passing a dynamically generated parameter for this table with the desired value (from SelectBox, from Input Text, from script, etc.)

+1
source

All Articles