Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7492143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:22:35+00:00 2026-05-29T16:22:35+00:00

I want to display all the project ‘s tasks in a page, given that

  • 0

I want to display all the project‘s tasks in a page, given that the user can have many projects. In such a case, a user will select any one project from the drop-down list box and I find that project instance using :

    def proj = params.managersProject // this is the choice made by the manager 
    def project = Project.findByName("$proj")

Now I have all the details in project instance. Now I need to display the tasks of that particular project. Since it have so many tasks, I need to paginate it. But for paginating to work properly, I guess we need to pass the params like this :

Project.list(params) // which will be passed on to the views for rendering. 

But in my case, I couldn’t able to call that list() method on project instance, that I got earlier. How do I solve this?

Edit:

After got answer from tim_yates, I tried this:

 def tasks = Tasks.findAllByProject( project, params )
    def size = tasks.size()
    params.max = Math.min(params.max ? params.int('max') : 10,100)
    return [tasksInstanceList: Tasks.findAllByProject(project,params), tasksInstanceTotal: size]

This returns the result, but when I click on the next button I don’t see any table being rendered. After that when I click on prev button, I couldn’t see anything. I clearly know that there is some problem with tasksInstanceList, I’m not sure whether the params is passing into it or not. But when I click on prev and next button I can clearly see my browsers add changing from :

http://localhost:8080/app/controller?offset=0&max=10

to:

http://localhost:8080/app/controller?offset=10&max=10

In view file I have this code:

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

Since I’m very new to grails, I need some help.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:22:36+00:00Added an answer on May 29, 2026 at 4:22 pm

    I may not be the perfect expert on pagination (I typically trip a bit over it myself) but if its the project’s Tasks hasmany property you’re trying to paginate through, Project.list() probably isn’t what you want.

    If your params has a .max and .offset (as in, you’re using the < g:paginate > tag and you provided it with a task listing controller action), what I typically do is use a criteriaBuilder with the somewhat-obscured PagedResultList return type. I’m guessing there’s a better way to go about it, but something like

    def yourProjectInstance = Project.get(params.yourProjectId)
    def taskPagedResult = Task.createCriteria().list(max: params.max as Integer, offset: params.offset as Integer) {
      eq('project', yourProjectInstance)
      //optionally, if you're using sortableColumn here as well, you can do
      //order(params.sort, params.order)
    }
    
    render view: 'taskPagedTable', model: [taskList: taskPagedResult, taskCount: taskPagedResult.totalCount()]
    

    Should put a list of params.max Tasks in your view’s taskList, but still give you the total number of tasks for that project in the taskCount variable.

    Hope that helps!

    Reference: http://blog.jeffshurts.com/2010/04/grails-pagination-and-criteriabuilder/

    EDIT:

    My guess is that what’s missing here is the action attribute for your paginate tag, especially if hitting the URL precisely is producing the proper results for you.
    You need to point your paginate tag at whatever controller action has your code block.

    One other thing I can think of looking at your controller code is your size variable might be misleading; it’s going to be the same as whatever params.max was. This is where the PagedResultList portion of my answer comes into play. Either that, or you could have size be equal to

    def size = Tasks.countByProject(project)
    

    That way your g:paginate tag’s total property will be accurate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
I want to display all records from table of current autorized user in my
I have a an array of observable collections and I want to display all
I have a following code , I want to display all the attributes of
I have a custom field name front_sl_slider. I want to display all the posts
I have a Microsoft SQL 2005, reporting project. I want to display the Current
in my project I want to display many objects (spheres) using vbo. I manage
i want to display all posts in Post table with say id=5 ...... controller
I want to display all the possible enum values as Radio buttons. I am
I'm working on Ubuntu.(Linux) I want to display all .php pages to .html in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.