Where() does not work in getPaginator of QueryBuilder

24 views
Skip to first unread message

Terry

unread,
Nov 5, 2012, 10:35:16 PM11/5/12
to scooter-...@googlegroups.com
Hi John,

Thanks for your reply of my last post.

I follow your suggestion to use the QueryBuilder to get the Paginator. But it does not work.

I traced the source code,
QueryBuilder where(String conditionsSQL) can initialize the conditionsSQL field of QueryBuilder, but this field is never used in getPaginator. It is only for getRecord()/getRecords().

Could you please take a look?

Thanks.

John Chen

unread,
Nov 6, 2012, 12:44:25 AM11/6/12
to scooter-...@googlegroups.com
Sorry, here attached is a fix of this bug.

The sample action method is the following by using examples/blog sample:
(scooter\webapps\blog\WEB-INF\src\blog\controllers\PostsController.java)
    public String index() {
        if ("true".equals(p(Constants.PAGED)) || p("npage") != null) {
            int npage = (p("npage") != null) ? Integer.parseInt(p("npage")) : 1;
            int limit = 5;
            String conditionsSQL = "1=1";
            Paginator page = Post.page(npage).limit(limit).where(conditionsSQL).getPaginator();
            setViewData("post_page", page);
            return renderView("paged_list");
        }
        setViewData("posts", Post.findAll());
        return null;
    }

John
scooter.jar

Terry

unread,
Nov 6, 2012, 2:04:40 AM11/6/12
to scooter-...@googlegroups.com
Thanks John. I tested it, and it works well.

Only one glitch, the example code lost the "paged=true" option in each page link.

What I did to solve it was only show the paged list.
if(true) {
int npage=...;
//your example code ..
}

在 2012年11月6日星期二UTC+8下午1时44分26秒,Scooter Framework写道:
Reply all
Reply to author
Forward
0 new messages