Search in sources :

Example 1 with FatalErrorPage

use of com.github.bordertech.wcomponents.FatalErrorPage in project wcomponents by BorderTech.

the class AbstractContainerHelper method renderErrorPageToHTML.

/**
 * Render the error page component to HTML.
 *
 * @param errorPage the error page component
 * @return the error page as HTML
 */
protected String renderErrorPageToHTML(final WComponent errorPage) {
    // Check if using the default error page
    boolean defaultErrorPage = errorPage instanceof FatalErrorPage;
    String html = null;
    // If not default implementation of error page, Transform error page to HTML
    if (!defaultErrorPage) {
        // Set UIC and Environment (Needed for Theme Paths)
        UIContext uic = new UIContextImpl();
        uic.setEnvironment(createEnvironment());
        UIContextHolder.pushContext(uic);
        try {
            html = WebUtilities.renderWithTransformToHTML(errorPage);
        } catch (Exception e) {
            LOG.warn("Could not transform error page.", e);
        } finally {
            UIContextHolder.popContext();
        }
    }
    // Not transformed. So just render.
    if (html == null) {
        UIContextHolder.pushContext(new UIContextImpl());
        try {
            html = WebUtilities.render(errorPage);
        } catch (Exception e) {
            LOG.warn("Could not render error page.", e);
            html = "System error occurred but could not render error page.";
        } finally {
            UIContextHolder.popContext();
        }
    }
    return html;
}
Also used : FatalErrorPage(com.github.bordertech.wcomponents.FatalErrorPage) UIContext(com.github.bordertech.wcomponents.UIContext) UIContextImpl(com.github.bordertech.wcomponents.UIContextImpl) IOException(java.io.IOException) SystemException(com.github.bordertech.wcomponents.util.SystemException)

Aggregations

FatalErrorPage (com.github.bordertech.wcomponents.FatalErrorPage)1 UIContext (com.github.bordertech.wcomponents.UIContext)1 UIContextImpl (com.github.bordertech.wcomponents.UIContextImpl)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1 IOException (java.io.IOException)1