I've the following method in my controller, that is used to list the Patient entities:
def list(Integer max) {
params.max = Math.min(max ?: 10, 100)
def roles = springSecurityService.getPrincipal().getAuthorities()
if(roles == 'ROLE_USER')
{
[patientInstanceList: Patient.findAllBySecUser(springSecurityService.getCurrentUser()), patientInstanceTotal: Patient.count()]
}
else if(roles == 'ROLE_ADMIN' || roles == 'ROLE_MANAGER')
{
[patientInstanceList: Patient.list(params), patientInstanceTotal: Patient.count()]
}
}
If I perform this method I have the exception
Tag [paginate] is missing required attribute [total]
But, if I use the following
def list(Integer max) {
params.max = Math.min(max ?: 10, 100)
[patientInstanceList: Patient.list(params), patientInstanceTotal: Patient.count()]
}
}
Everything works well. I see all the instances of Patient created. I only want that, based on role of user logged in, I can see a part of all the entities created. Why does this exception is raised?
I've found here Grails pagination tag error something similar, but no good answer was given