Title: Grails Pagination - Issue not to load images with freewall js
Tags: javascript;jquery;grails
Question: GRAILS
Controller
def beta() {
params.max = Math.min(params.max ?: 10, 100)
params.offset = Math.min(params.offset ?: 10, 100)
def l = Portfolio.findAllByPublished(true, params)
int total =  Portfolio.countByPublished(true)
withFormat {
html {
[list:l, portfolioInstanceTotal: total]
}
json {
render l as JSON
}
}
GSP template
<div class="pagination"&gt;
<g:paginate omitPrev="true" omitNext="true" controller="designer" action="beta" total="${portfolioInstanceTotal}" /&gt;
</div&gt;
I also use JQuery with freewall js to append the images in grid. I try to append the images to pagination, but I got errors as u can see on stacktrace.
Thanks!
Comment: Can you show the rest of the stacktrace please?

Comment: It looks like either params.max or params.offset is returning a string. Can you try parsing it as an integer?

Here is the accepted answer: Request parameters are Strings. So params.offset returns a String.
Calling Math method with String as parameter throws an exception.
You should convert the String to int first:
params.max = Math.min(params.max.toInteger() ?: 10, 100)


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:01/22/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><jquery><grails>', 'Title': 'Grails Pagination - Issue not to load images with freewall js', 'ViewCount': 240, 'id': 21274483, 'user_AboutMe': '', 'user_AccountId': 2242424.0, 'user_DisplayName': 'kittymeows', 'user_Reputation': 183.0, 'user_Views': 60.0, 'user_id': 2829887.0}}