Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package viewmodel;
import play.mvc.QueryStringBindable;
import java.util.Map;
import java.util.Optional;
public class PaginationParams implements QueryStringBindable<PaginationParams> {
private int page;
private int offset;
private int limit;
public int getPage() {
return page;
public void setPage(int page) { = page;
public int getOffset() {
return offset;
public void setOffset(int offset) {
this.offset = offset;
public int getLimit() {
return limit;
public void setLimit(int limit) {
this.limit = limit;
public Optional<PaginationParams> bind(String key, Map<String, String[]> parameters) {
final String page = parameters.get("page")[0];
final String offset = parameters.get("offset")[0];
final String limit = parameters.get("limit")[0]; = Integer.parseInt(page);
this.offset = Integer.parseInt(offset);
this.limit = Integer.parseInt(limit);
return Optional.of(this);
public String unbind(String key) {
return null;
public String javascriptUnbind() {
return null;
package controllers;
import play.mvc.Controller;
import play.mvc.Result;
import viewmodel.PaginationParams;
public class PaginationParamsTest extends Controller {
public Result test(PaginationParams paginationParams) {
final int limit = paginationParams.getLimit();
final int offset = paginationParams.getOffset();
final int page = paginationParams.getPage();
return ok("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.