@Override public String view() { return req().response().view(); }
private static boolean shouldRenderView(Resp resp) { if (!resp.mvc()) return false; Object result = resp.result(); if (result == null) return true; if (((RespImpl) resp).hasCustomView()) return U.notEmpty(resp.view()); return true; }
protected Object defaultErrorHandling(Req req, Throwable error) { if (error instanceof NotFound) { Resp resp = req.response().code(404); if (resp.contentType() == MediaType.JSON) { return error; } else { return resp.view("404").result(U.map("req", req)); } } return error; }
protected Object page(Req req, Resp resp, Throwable error) { if (error instanceof SecurityException) { resp.model("embedded", req.attr("_embedded", false)); resp.model("req", req); resp.model("loginUri", Msc.specialUri("login")); return resp.code(403).view("login").mvc(true); } else { BasicConfig zone = HttpUtils.zone(req); String home = zone.entry("home").or("/"); Map<String, ?> errorInfo = HttpUtils.getErrorInfo(resp, error); resp.model("req", req); resp.model("error", errorInfo); resp.model("home", home); return resp.mvc(true).view("error"); } }
@SuppressWarnings("unchecked") public static boolean renderView(ReqImpl req, Resp resp, Object result, boolean mandatory, ByteArrayOutputStream out) { String viewName = resp.view(); HttpUtils.validateViewName(viewName);
private void execHandlerJob(final Channel channel, final boolean isKeepAlive, final MediaType contentType, final Req req) { With.tag(CTX_TAG_HANDLER).exchange(req).run(() -> { try { req.response() .view(options.view()) .contentType(options.contentType()) .mvc(options.mvc()); handleWithWrappers(channel, isKeepAlive, contentType, req, wrappers.get()); } catch (Throwable e) { handleError(req, e); } }); }
@Override public String view() { return req().response().view(); }
private static boolean shouldRenderView(Resp resp) { if (!resp.mvc()) return false; Object result = resp.result(); if (result == null) return true; if (((RespImpl) resp).hasCustomView()) return U.notEmpty(resp.view()); return true; }
protected Object defaultErrorHandling(Req req, Throwable error) { if (error instanceof NotFound) { Resp resp = req.response().code(404); if (resp.contentType() == MediaType.JSON) { return error; } else { return resp.view("404").result(U.map("req", req)); } } return error; }
@Override public void run() { try { req.response() .view(options.view()) .contentType(options.contentType()) .mvc(options.mvc()); handleWithWrappers(channel, isKeepAlive, contentType, req, wrappers.get()); } catch (Throwable e) { handleError(req, e); } }
protected Object page(Req req, Resp resp, Throwable error) { if (error instanceof SecurityException) { resp.model("embedded", req.attr("_embedded", false)); resp.model("req", req); resp.model("loginUri", Msc.specialUri("login")); return resp.code(403).view("login").mvc(true); } else { BasicConfig zone = HttpUtils.zone(req); String home = zone.entry("home").or("/"); Map<String, ?> errorInfo = HttpUtils.getErrorInfo(resp, error); resp.model("req", req); resp.model("error", errorInfo); resp.model("home", home); return resp.mvc(true).view("error"); } }
@SuppressWarnings("unchecked") public static boolean renderView(ReqImpl req, Resp resp, Object result, boolean mandatory, ByteArrayOutputStream out) { String viewName = resp.view(); HttpUtils.validateViewName(viewName);