Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do pagination using java in play framework?

I am doing pagination in my web app so how to do this ?

what i want is : i wan to show all the users to admin!

i went through this play framework computer app computer-database but i don't want this type of pagination computer -database app pagination is :

enter image description here

but i want like google :

enter image description here

my query same like computer-database app:

model part of user

public static Page<User> page(int page, int pageSize, String sortBy, String order, String filter) {
        return 
            find.where()
                .ilike("name", "%" + filter + "%")
                .orderBy(sortBy + " " + order)
                .findPagingList(pageSize)
                .getPage(page);
    }

view is:

adm.scala.html

and contoller is :

public static Result enter() {
        Form<Login> loginForm = Form.form(Login.class).bindFromRequest();

        if (loginForm.hasErrors()) {
            return badRequest(logi.render(loginForm));// errorsAsJson());
        }

        if(loginForm.get().email.equals("[email protected]") ) {

            return redirect(routes.paging.pag(0, "name", "asc", ""));

        }

and paging.java

public class paging extends Controller {

    public static Result pag(int page, String sortBy, String order, String filter) throws ClassNotFoundException, SQLException {

return ok(adm.render(User.page(page, 2, sortBy, order, filter),
                sortBy, order, filter));

    }

Give me some idea for that pagination.

like image 934
Rahul Kulhari Avatar asked May 27 '26 14:05

Rahul Kulhari


1 Answers

You can use paginate module on play, try this

like image 89
barssala Avatar answered May 30 '26 03:05

barssala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!