com.jfinal.render.JsonRender Java Examples
The following examples show how to use
com.jfinal.render.JsonRender.
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: ComActionInterceptor.java From my_curd with Apache License 2.0 | 6 votes |
@Override public void intercept(Invocation inv) { inv.getController().setAttr("setting", Constant.SETTING); String errMsg = null; try { inv.invoke(); } catch (Exception e) { log.error(e.getMessage(), e); errMsg = ExceptionUtils.getMessage(e); } // 返回异常信息 if (StringUtils.notEmpty(errMsg)) { String requestType = inv.getController().getRequest().getHeader("X-Requested-With"); if ("XMLHttpRequest".equals(requestType) || StringUtils.notEmpty(inv.getController().getPara("xmlHttpRequest"))) { Ret ret = Ret.create().set("state", "error").set("msg", errMsg); inv.getController().render(new JsonRender(ret).forIE()); } else { inv.getController().setAttr("errorMsg", errMsg); inv.getController().render(Constant.VIEW_PATH + "/common/500.ftl"); } } }
Example #2
Source File: BaseController.java From my_curd with Apache License 2.0 | 5 votes |
/** * 返回datagrid json 数据 * * @param pageData */ protected void renderDatagrid(Page<?> pageData) { Map<String, Object> datagrid = new HashMap<>(); datagrid.put("rows", pageData.getList()); datagrid.put("total", pageData.getTotalRow()); render(new JsonRender(datagrid).forIE()); }
Example #3
Source File: BaseController.java From my_curd with Apache License 2.0 | 5 votes |
/** * 返回datagrid json 数据 * * @param list * @param total * @param footer */ @SuppressWarnings({"SameParameterValue", "WeakerAccess"}) protected void renderDatagrid(List<?> list, int total, List<Map<String, Object>> footer) { Map<String, Object> datagrid = new HashMap<>(); datagrid.put("rows", list); datagrid.put("total", total); if (footer != null && footer.size() > 0) { datagrid.put("footer", footer); } render(new JsonRender(datagrid).forIE()); }
Example #4
Source File: BaseController.java From my_curd with Apache License 2.0 | 4 votes |
public void renderDatagrid(Collection collection, int total) { Map<String, Object> datagrid = new HashMap<>(); datagrid.put("rows", collection); datagrid.put("total", total); render(new JsonRender(datagrid).forIE()); }
Example #5
Source File: BaseController.java From my_curd with Apache License 2.0 | 4 votes |
/** * 成功操作 */ protected void renderSuccess() { Ret ret = Ret.create().setOk(); render(new JsonRender(ret).forIE()); }
Example #6
Source File: BaseController.java From my_curd with Apache License 2.0 | 4 votes |
/** * 失败操作 */ protected void renderFail() { Ret ret = Ret.create().setFail(); render(new JsonRender(ret).forIE()); }
Example #7
Source File: BaseController.java From my_curd with Apache License 2.0 | 2 votes |
/** * 成功操作 * * @param msg */ protected void renderSuccess(String msg) { Ret ret = Ret.create().setOk().setIfNotNull("msg", msg); render(new JsonRender(ret).forIE()); }
Example #8
Source File: BaseController.java From my_curd with Apache License 2.0 | 2 votes |
/** * 成功操作 * * @param data */ protected void renderSuccess(List<Object> data) { Ret ret = Ret.create().setOk().setIfNotNull("data", data); render(new JsonRender(ret).forIE()); }
Example #9
Source File: BaseController.java From my_curd with Apache License 2.0 | 2 votes |
/** * 成功操作 * * @param msg * @param data */ protected void renderSuccess(String msg, List<Object> data) { Ret ret = Ret.create().setOk().setIfNotNull("msg", msg).setIfNotNull("data", data); render(new JsonRender(ret).forIE()); }
Example #10
Source File: BaseController.java From my_curd with Apache License 2.0 | 2 votes |
/** * 失败操作 * * @param msg */ protected void renderFail(String msg) { Ret ret = Ret.create().setFail().setIfNotNull("msg", msg); render(new JsonRender(ret).forIE()); }
Example #11
Source File: BaseController.java From my_curd with Apache License 2.0 | 2 votes |
/** * 失败操作 * * @param data */ protected void renderFail(List<Object> data) { Ret ret = Ret.create().setFail().setIfNotNull("data", data); render(new JsonRender(ret).forIE()); }
Example #12
Source File: BaseController.java From my_curd with Apache License 2.0 | 2 votes |
/** * 失败操作 * * @param msg * @param data */ protected void renderFail(String msg, List<Object> data) { Ret ret = Ret.create().setFail().setIfNotNull("msg", msg).setIfNotNull("data", data); render(new JsonRender(ret).forIE()); }