Проблемы с Grails paginate

I have a simple paginate issue and get the following error... 
Hoping for some advice. I am relearning grails using version 2.1 and when I attempt to make a page with the paginate section is it failing.


Error 500: Internal Server Error
URI
/tictoc/
Class
groovy.lang.MissingMethodException
Message
No signature of method: tictoc.Event.withCritera() is applicable for argument types: (tictoc.StoreController$_closure2_closure3) values: [tictoc.StoreController$_closure2_closure3@10cea05] Possible solutions: withCriteria(groovy.lang.Closure), withCriteria(java.util.Map, groovy.lang.Closure)
Around line 27 of grails-app\controllers\tictoc\StoreController.groovy
24: 
25: def total = Event.countByActive(true)
26: 
27: def eventList = Event.withCritera {
28: 
29: eq 'active', params.active
30: projections {
Around line 13 of grails-app\controllers\tictoc\StoreController.groovy
10: def show = {
11: 
12: log.error 'exec activeEvents'
13: activeEvents()
14:
15: }
16:

//Вот класс домена, и я использую активное поле для поиска withCritera. Я хотел, чтобы это было логическим значением, но я не был уверен, что он работает.

package tictoc

import java.math.BigInteger

class Event implements Cloneable {

 Integer id
 String name
 Date startDate
 Date endDate
 String desc
 String active 

 static constraints = {
 name(nullable:true)
 startDate(nullable:true)
 endDate(nullable:true)
 desc(nullable:true)
 active(nullable:true)
 }

 public String toString(){
 return "id:" + this.id + 
 " name:" + this.name + 
 " startDate:" + this.startDate +
 " endDate:" + this.endDate;
 }

 public int hashCode() {
 int hash = 1
 hash = hash * 31 + id.hashCode()
 hash = hash * 31 + name.hashCode()
 hash = hash * 31 + this.startDate
 hash = hash * 31 + this.endDate
 return hash
 }

 public boolean equals(Object anObject) {

 if (anObject != null &&
 anObject instanceof Event)
 {
 Ticket aThing = (Ticket)anObject;
 return (this.id == aThing.id) && 
 (this.name == aThing.name) && 
 (this.startDate == aThing.startDate) && 
 (this.endDate == aThing.endDate)
 }

 return false;
 }
}

//Здесь GSP и раздел paginate не показывали следующие/предыдущие кнопки:

<%@ page import="tictoc.Store" %>


 
 
 <g:set var="entityName" value="${message(code: 'store.label', default: 'Store')}">
 <title><g:message code="default.show.label" args="[entityName]" /></title>
 
 

 <h2> Ticket Store </h2>

 <g:each var="event" in="${events}">

 </g:each><table border="0">
 <tbody><tr>
 <th>Event</th>
 <th>Start </th>
 <th>End </th>
 <th>Description</th>
 </tr>
 <tr>
 <td>${event.name}</td>
 
 
 <td>${event.desc}</td>
 </tr>

 
 </tbody></table>

 <div>
 <g:paginate controller="store" action="activeEvents" params="[name:active]" total="${totalEvents}">
 </g:paginate></div>
 


Here is the controller and i set the default page to activeEvents :

package tictoc

import tictoc.Event 

class StoreController {

 Event event
 static defaultAction = "activeEvents"

 def activeEvents = {
 log.error 'exec activeEvents'
 def max = Math.min(params.max?.toInteger() ?:10, 100)
 def offset = params.offset?.toInteger() ?: 0
 def total = Event.countByActive(true)
 def eventList = Event.withCritera {

 eq 'active', params.active
 projections {
 event {

 order 'name'
 }
 }
 maxResults max
 firstResult offset
 }

 return [events:eventList, 
 totalEvents:total,
 active:params.active]
 }
}
</g:set>
1 ответ

Вы неправильно withCriteria.

licensed under cc by-sa 3.0 with attribution.