grails - How to display list items correctly in my paginated views -


this controller list games database.

def index() {     def platform = gameservice.listplatform()     def max = params.max ?: 10     def offset = params.offset ?: 0     def chosenplatfrm = params.platform     def tasklist = gameservice.listgameplat(chosenplatfrm,max,offset)     def taskl = gameservice.whatshot(chosenplatfrm,max,offset)     [games:taskl, bb:tasklist, chosenplatform:chosenplatfrm, platforms:platform, gamecount:taskl.totalcount, gamecont:tasklist.totalcount]   } 

this how index.gsp looks.

<g:each in="${games}" status="i" var="game">         <g:if test="${game.averagerating != 0 }">             <g:link action="gameprofile"                 params="${[gametitle: "${game.gametitle}"]}">             </g:link>         </g:if> </g:each> <div class="pagination" style="text-align: center;">         <g:paginate action="index" total="${gamecount}" offset="0" max="3" params="${params.max}"/> </div> 

i want limit paginated view 3 items every page. when index.gsp receives data index controller displays in list though have pagination tag, when clicked page number seems working fine.

i tried redirect in index controller displays error "error redirect loop"

 redirect(action: "index", params:[id:'',offset: '0', max: '3']) 

how display index.gsp correctly?

i think 1 problem in view. try:

<g:paginate total="${gamecount}" /> 

instead of:

<g:paginate action="index" total="${gamecount}" offset="0" max="3" params="${params.max}"/>      

another problem in controller: should write function count gamecount variable, count number of games in every paginated view (so without offset , limit parameter).

of course redirect wrong because executing controller's index() function on , on , on again, stay first provided code.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -