当前位置: 首页>>代码示例>>Java>>正文


Java ViewHandlerException类代码示例

本文整理汇总了Java中org.ofbiz.webapp.view.ViewHandlerException的典型用法代码示例。如果您正苦于以下问题:Java ViewHandlerException类的具体用法?Java ViewHandlerException怎么用?Java ViewHandlerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ViewHandlerException类属于org.ofbiz.webapp.view包,在下文中一共展示了ViewHandlerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleException

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
static void handleException(HttpServletRequest request, HttpServletResponse response, Exception ex, CmsCallType renderMode) throws ViewHandlerException {
        // 2017-03-24: only report detailed error if preview/debug mode
        if (renderMode == CmsCallType.OFBIZ_PREVIEW) {
            rethrowViewHandlerExceptionDetailed(request, ex);
        } else {
            if (CmsRenderUtil.getLiveExceptionMode(request.getServletContext()) == UtilRender.RenderExceptionMode.DEBUG) {
                rethrowViewHandlerExceptionDetailed(request, ex);
            } else {
                // OLD CODE: this was secure, but prevented controller from handling the error...
                // instead, rethrow an error with a generic message
//                try {
//                    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
//                } catch (IOException e1) {
//                    Debug.logError(e1, "Cms: Error sending server error response" + CmsControlUtil.getReqLogIdDelimStr(request), module);
//                }
                rethrowViewHandlerExceptionGeneric(request, ex);
            }
        }
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:20,代码来源:CmsScreenViewHandler.java

示例2: invokeViewHandlerAsJson

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
/**
 * SCIPIO: factored out viewAsJson view handler render wrapper code.
 */
public static void invokeViewHandlerAsJson(ViewHandler vh, ConfigXMLReader.ViewAsJsonConfig viewAsJsonConfig, String view, String nextPage, String info, String contentType, String charset, HttpServletRequest req, HttpServletResponse resp) throws ViewHandlerException {
    if (vh instanceof ViewHandlerExt) {
        ViewHandlerExt vhe = (ViewHandlerExt) vh;
        // SPECIAL: we must save _ERROR_MESSAGE_ and the like because the screen handler destroys them!
        Map<String, Object> msgAttrMap = ViewAsJsonUtil.getMessageAttributes(req);
        Writer sw = ViewAsJsonUtil.prepareWriterAndMode(req, viewAsJsonConfig);
        try {
            vhe.render(view, nextPage, info, contentType, charset, req, resp, sw);
        } finally {
            ViewAsJsonUtil.setRenderOutParamFromWriter(req, sw);
            ViewAsJsonUtil.setMessageAttributes(req, msgAttrMap);
        }
    } else {
        throw new ViewHandlerException("View handler does not support extended interface (ViewHandlerExt)");
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:20,代码来源:RequestHandler.java

示例3: render

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
public void render(String name, String page, String info, String contentType, String encoding,
        HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
    if (UtilValidate.isEmpty(page))
        throw new ViewHandlerException("Invalid template source");

    // make the root context (data model) for freemarker
    MapStack<String> context = MapStack.create();
    prepOfbizRoot(context, request, response);

    // process the template & flush the output
    try {
        if (page.startsWith("component://")) {
            FreeMarkerWorker.renderTemplateAtLocation(page, context, response.getWriter());
        } else {
            // backwards compatibility
            Template template = config.getTemplate(page);
            FreeMarkerWorker.renderTemplate(template, context, response.getWriter());
        }
        response.flushBuffer();
    } catch (TemplateException te) {
        throw new ViewHandlerException("Problems processing Freemarker template", te);
    } catch (IOException ie) {
        throw new ViewHandlerException("Problems writing to output stream", ie);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:26,代码来源:FreeMarkerViewHandler.java

示例4: renderError

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
protected void renderError(String msg, Exception e, String screenOutString, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
    Debug.logError(msg + ": " + e + "; Screen XSL:FO text was:\n" + screenOutString, module);
    try {
        Delegator delegator = (Delegator) request.getAttribute("delegator");
        Writer writer = new StringWriter();
        ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.name", delegator),
                EntityUtilProperties.getPropertyValue("widget", "screen.screenrenderer", delegator));
        ScreenRenderer screens = ScreenRenderer.makeWithEnvAwareFetching(writer, null, screenStringRenderer);
        screens.populateContextForRequest(request, response, servletContext);
        screens.getContext().put("errorMessage", msg + ": " + e);
        screens.render(DEFAULT_ERROR_TEMPLATE);
        response.setContentType("text/html");
        response.getWriter().write(writer.toString());
        writer.close();
    } catch (Exception x) {
        Debug.logError("Multiple errors rendering FOP", module);
        throw new ViewHandlerException("Multiple errors rendering FOP", x);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:20,代码来源:ScreenFopViewHandler.java

示例5: renderError

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
protected void renderError(String msg, Exception e, String screenOutString, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
    Debug.logError(msg + ": " + e + "; Screen XSL:FO text was:\n" + screenOutString, module);
    try {
        Writer writer = new StringWriter();
        ScreenRenderer screens = new ScreenRenderer(writer, null, new HtmlScreenRenderer());
        screens.populateContextForRequest(request, response, servletContext);
        screens.getContext().put("errorMessage", msg + ": " + e);
        screens.render(DEFAULT_ERROR_TEMPLATE);
        response.setContentType("text/html");
        response.getWriter().write(writer.toString());
        writer.close();
    } catch (Exception x) {
        Debug.logError("Multiple errors rendering FOP", module);
        throw new ViewHandlerException("Multiple errors rendering FOP", x);
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:17,代码来源:ScreenFopViewHandler.java

示例6: init

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
public void init(ServletContext context) throws ViewHandlerException {
    rootDir = context.getRealPath("/");
    https = (String) context.getAttribute("https");
    defaultCharset = context.getInitParameter("charset");
    if (UtilValidate.isEmpty(defaultCharset)) {
        defaultCharset = "UTF-8";
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:9,代码来源:SimpleContentViewHandler.java

示例7: init

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
@Override
public void init(ServletContext context) throws ViewHandlerException {
    super.init(context);
    this.servletContext = context;

    this.defaultCmsPage = new CmsPageInfo(this.webSiteConfig.getDefaultCmsPageId());
    
    this.renderInvoker = RenderInvoker.getRenderInvoker(context);
    
    // hasControllerHint true because if there's a view handler there has to be a controller...
    CmsWebSiteInfo webSiteInfo = CmsWebSiteInfo.registerCmsWebSite(context, true);
    this.webSiteConfig = CmsWebSiteInfo.getWebSiteConfigOrDefaults(webSiteInfo, servletContext);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:14,代码来源:CmsScreenViewHandler.java

示例8: renderScreen

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
private void renderScreen(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response, Writer writer) throws ViewHandlerException {
    if (CmsUtil.verboseOn()) {
        Debug.logInfo("Cms: Starting legacy screen widget render process" + CmsControlUtil.getReqLogIdDelimStr(request), module);
    }
    
    if (webSiteConfig.isSetResponseBrowserNoCacheScreen()) {
        if (CmsUtil.verboseOn()) {
            Debug.logInfo("Cms: Setting browser no-proxy no-cache response" + CmsControlUtil.getReqLogIdDelimStr(request), module);
        }
        CmsControlUtil.checkSetNoCacheResponse(request, response);
    }
    
    super.render(name, page, info, contentType, encoding, request, response, writer); 
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:15,代码来源:CmsScreenViewHandler.java

示例9: render

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
@Override
public void render(String name, String page, String info, String contentType, String encoding,
        HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
    Writer writer;
    try {
        writer = CmsControlUtil.getResponseWriter(request, response);
    } catch (IOException e) {
        Debug.logError(e, "Cms: Error getting response writer: " + e.getMessage() + CmsControlUtil.getReqLogIdDelimStr(request), module);
        handleException(request, response, e, null);
        return;
    }
    this.render(name, page, info, contentType, encoding, request, response, writer);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:14,代码来源:CmsScreenViewHandler.java

示例10: render

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
@Override
public void render(String name, String page, String info, String contentType, String encoding,
        HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
    try {
        this.render(name, page, info, contentType, encoding, request, response, response.getWriter());
    } catch (IOException e) {
        throw new ViewHandlerException("Error in the response writer/output stream: " + e.toString(), e);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:10,代码来源:MacroScreenViewHandler.java

示例11: viewHandlerRender

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
protected void viewHandlerRender(String typeToUse, HttpServletRequest request, HttpServletResponse response) throws ServletException {
    ServletContext context = (ServletContext) request.getAttribute("servletContext");
    RequestHandler requestHandler = (RequestHandler) context.getAttribute("_REQUEST_HANDLER_");

    // see if the type is defined in the controller.xml file
    try {
        if (Debug.verboseOn()) Debug.logVerbose("Rendering view [" + content + "] of type [" + typeToUse + "]", module);
        ViewHandler vh = requestHandler.getViewFactory().getViewHandler(typeToUse);
        // use the default content-type and encoding for the ViewHandler -- may want to change this.
        vh.render(name, content, info, null, null, request, response);
    } catch (ViewHandlerException e) {
        throw new ServletException(e.getNonNestedMessage(), e.getNested());
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:15,代码来源:Section.java

示例12: renderCmsPage

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
/**
     * Renders page.
     * <p>
     * DEV NOTE: do not use the "path" parameter.
     * 
     * @return false if must prevent any further web response
     */
    private boolean renderCmsPage(HttpServletRequest request, HttpServletResponse response, String path, CmsPage cmsPage, CmsView cmsView, String webSiteId, CmsCallType renderMode, Writer writer) throws ViewHandlerException {
        
        // We must make sure that if for whatever reason a transaction is in place, maybe
        // some runaway transaction, we kill it now, because the CMS rendering happens in a 
        // different thread and this could end in a total lockup if read/writing the same entity 
        // value if keep a transaction here.
        // Note: I wasn't sure if should do commit/rollback or suspend/resume here/after, 
        // but I'm not sure implications of suspend w.r.t. multithread here so doing commit/rollback for now
        endTransactionAlways(request, response);
        
        if (CmsUtil.verboseOn()) {
            Debug.logInfo("Cms: Starting CMS page render process" + CmsControlUtil.getReqLogIdDelimStr(request), module);
        }
        
        if (webSiteConfig.isSetResponseBrowserNoCacheCmsPage()) {
            if (CmsUtil.verboseOn()) {
                Debug.logInfo("Cms: Setting browser no-proxy no-cache response" + CmsControlUtil.getReqLogIdDelimStr(request), module);
            }
            CmsControlUtil.checkSetNoCacheResponse(request, response);
        }
        
        try {
            
            // Main render invocation
            renderInvoker.invokeCmsRendering(request, response, servletContext, cmsPage, cmsView, webSiteId, renderMode, writer);
            
        // NOTE: 2016: this is never thrown from local cms renders, but leaving here for future use
//        } catch (CmsCallHttpException e) {
//            
//            int httpStatus = e.getHttpStatus();
//            int returnCode = passOnHttpStatusesFromCms.contains(httpStatus) ? httpStatus : HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
//
//            Exception exToPrint = e;
//            if (returnCode == HttpServletResponse.SC_NOT_FOUND) {
//                // too verbose
//                exToPrint = null;
//            }
//            
//            Debug.logError(exToPrint, "Cms: Error rendering page " + cmsPage.getLogIdRepr() + 
//                    " for view " + cmsView.getLogIdRepr() + " via CMS invocation: " + e.getMessage() + CmsControlUtil.getReqLogIdDelimStr(request), module);
//            try {
//                
//                response.sendError(returnCode);
//            } catch (IOException e1) {
//                Debug.logError(e1, "Cms: Error sending server error response" + CmsControlUtil.getReqLogIdDelimStr(request), module);
//            }
//            return false; // Nothing can be sent after this
        } catch (Exception e) {
            Debug.logError(e, "Cms: Error rendering page " + cmsPage.getLogIdRepr() + 
                    " for view " + cmsView.getLogIdRepr() + " via CMS invocation: " + e.getMessage() + CmsControlUtil.getReqLogIdDelimStr(request), module);
            handleException(request, response, e, renderMode);
            return false; // Nothing can be sent after this
        }
        return true;
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:63,代码来源:CmsScreenViewHandler.java

示例13: rethrowViewHandlerExceptionGeneric

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
static void rethrowViewHandlerExceptionGeneric(HttpServletRequest request, Exception ex) throws ViewHandlerException {
    final String msg = RequestUtil.getGenericErrorMessage(request);
    throw new ViewHandlerException(msg, new Exception(msg));
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:5,代码来源:CmsScreenViewHandler.java

示例14: init

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
public void init(ServletContext context) throws ViewHandlerException {
    config.setCacheStorage(new OfbizCacheStorage("unknown"));
    config.setServletContextForTemplateLoading(context, "/");
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:5,代码来源:FreeMarkerViewHandler.java

示例15: init

import org.ofbiz.webapp.view.ViewHandlerException; //导入依赖的package包/类
/**
 * @see org.ofbiz.webapp.view.ViewHandler#init(javax.servlet.ServletContext)
 */
@Override
public void init(ServletContext context) throws ViewHandlerException {
    this.servletContext = context;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:8,代码来源:ScreenFopViewHandler.java


注:本文中的org.ofbiz.webapp.view.ViewHandlerException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。