Java Code Examples for com.jfinal.core.Controller#getParaToInt()
The following examples show how to use
com.jfinal.core.Controller#getParaToInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArticlePageDirective.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onRender(Env env, Scope scope, Writer writer) { Controller controller = JbootControllerContext.get(); int page = controller.getParaToInt(1, 1); int pageSize = getParaToInt("pageSize", scope, 10); String orderBy = getPara("orderBy", scope, "id desc"); // 可以指定当前的分类ID Long categoryId = getParaToLong("categoryId", scope, 0L); ArticleCategory category = controller.getAttr("category"); if (categoryId == 0 && category != null) { categoryId = category.getId(); } Page<Article> articlePage = categoryId == 0 ? service.paginateInNormal(page, pageSize, orderBy) : service.paginateByCategoryIdInNormal(page, pageSize, categoryId, orderBy); scope.setGlobal("articlePage", articlePage); renderBody(env, scope, writer); }
Example 2
Source File: ProductPageDirective.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onRender(Env env, Scope scope, Writer writer) { Controller controller = JbootControllerContext.get(); int page = controller.getParaToInt(1, 1); int pageSize = getParaToInt("pageSize", scope, 10); String orderBy = getPara("orderBy", scope, "id desc"); // 可以指定当前的分类ID Long categoryId = getParaToLong("categoryId", scope, 0L); ProductCategory category = controller.getAttr("category"); if (categoryId == 0 && category != null) { categoryId = category.getId(); } Page<Product> productPage = categoryId == 0 ? service.paginateInNormal(page, pageSize, orderBy) : service.paginateByCategoryIdInNormal(page, pageSize, categoryId, orderBy); scope.setGlobal("productPage", productPage); renderBody(env, scope, writer); }
Example 3
Source File: SearchSql.java From my_curd with Apache License 2.0 | 5 votes |
public void intercept(Invocation ai) { Controller c = ai.getController(); // 查询字段前缀 String prefix = "search_"; // 获得 查询 参数 Map<String, Object> searchParams = getParametersStartingWith(c.getRequest(), prefix); // 获得 查询 所有的 查询 filter Map<String, SearchFilter> filters = SearchFilter.parse(searchParams); // 根据 filter 获得 wheresql 语句 String whereSql = buildFilter(filters.values()); c.setAttr(Constant.SEARCH_SQL, whereSql); int pageNumber = c.getParaToInt("page", 1); int pageSize = c.getParaToInt("rows", 1); //分页参数, 兼容 bootstrap 分页 和 easyui grid 分页 // int pageNumber; // int pageSize; // if (StrKit.notBlank(c.getPara("offset"))) { // // bootstraptable 分页 // pageNumber = c.getParaToInt("offset", 0); // pageSize = c.getParaToInt("limit", 10); // if (pageNumber != 0) {// 获取页数 // pageNumber = pageNumber / pageSize; // } // pageNumber += 1; // } else { // // easyui grid 分页 // pageNumber = c.getParaToInt("page", 1); // pageSize = c.getParaToInt("rows", 1); // } c.setAttr("pageNumber", pageNumber); c.setAttr("pageSize", pageSize); ai.invoke(); }
Example 4
Source File: PageCommentPageDirective.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onRender(Env env, Scope scope, Writer writer) { Controller controller = JbootControllerContext.get(); int page = controller.getParaToInt(1, 1); int pageSize = getParaToInt("pageSize", scope, 10); SinglePage singlePage = controller.getAttr("page"); if (singlePage != null) { Page<SinglePageComment> articlePage = service.paginateByPageIdInNormal(page, pageSize, singlePage.getId()); scope.setGlobal("commentPage", articlePage); renderBody(env, scope, writer); } }
Example 5
Source File: CommentPageDirective.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onRender(Env env, Scope scope, Writer writer) { Controller controller = JbootControllerContext.get(); int page = controller.getParaToInt(1, 1); int pageSize = getParaToInt("pageSize", scope, 10); Article article = controller.getAttr("article"); if (article != null) { Page<ArticleComment> articlePage = service.paginateByArticleIdInNormal(page, pageSize, article.getId()); scope.setGlobal("commentPage", articlePage); renderBody(env, scope, writer); } }
Example 6
Source File: ProductCommentPageDirective.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onRender(Env env, Scope scope, Writer writer) { Controller controller = JbootControllerContext.get(); int page = controller.getParaToInt(1, 1); int pageSize = getParaToInt("pageSize", scope, 10); Product product = controller.getAttr("product"); if (product != null) { Page<ProductComment> articlePage = service.paginateByProductIdInNormal(page, pageSize, product.getId()); scope.setGlobal("commentPage", articlePage); renderBody(env, scope, writer); } }