Search in sources :

Example 1 with FacesContextEx

use of com.ibm.xsp.context.FacesContextEx in project org.openntf.domino by OpenNTF.

the class PhaseListener method doBeforeEveryPhase.

/**
 * Method to run before every phase is triggered
 *
 * @param arg0
 *            PhaseEvent currently being run
 * @since org.openntf.domino.xsp 2.5.0
 */
private void doBeforeEveryPhase(final PhaseEvent arg0) {
    FacesContext ctx = arg0.getFacesContext();
    Factory.setClassLoader(Thread.currentThread().getContextClassLoader());
    if (ctx instanceof FacesContextEx) {
        FacesContextEx ctxex = (FacesContextEx) ctx;
        ctxex.addRequestListener(this);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) FacesContextEx(com.ibm.xsp.context.FacesContextEx)

Example 2 with FacesContextEx

use of com.ibm.xsp.context.FacesContextEx in project org.openntf.domino by OpenNTF.

the class ODAFacesContextFactory method getFacesContext.

@Override
public FacesContext getFacesContext(final Object context, final Object request, final Object response, final Lifecycle lifecycle) throws FacesException {
    FacesContext ctx = _delegate.getFacesContext(context, request, response, lifecycle);
    Factory.initThread(ODAPlatform.getAppThreadConfig(null));
    Factory.setSessionFactory(new XPageCurrentSessionFactory(), SessionType.CURRENT);
    Factory.setSessionFactory(new XPageSignerSessionFactory(false), SessionType.SIGNER);
    Factory.setSessionFactory(new XPageSignerSessionFactory(true), SessionType.SIGNER_FULL_ACCESS);
    // TODO RPr: This is probably the wrong locale. See ViewHandler.calculateLocale
    Factory.setUserLocale(ctx.getExternalContext().getRequestLocale());
    Factory.setClassLoader(ctx.getContextClassLoader());
    if (ODAPlatform.isAppGodMode(null)) {
        ODAFacesContext localContext = new ODAFacesContext(ctx);
        attachListener(localContext);
        return localContext;
    } else {
        if (ctx instanceof FacesContextEx) {
            attachListener((FacesContextEx) ctx);
            return ctx;
        } else {
            DominoFacesContext localContext = new DominoFacesContext(ctx);
            attachListener(localContext);
            return localContext;
        }
    }
}
Also used : DominoFacesContext(com.ibm.xsp.domino.context.DominoFacesContext) FacesContext(javax.faces.context.FacesContext) XPageCurrentSessionFactory(org.openntf.domino.xsp.session.XPageCurrentSessionFactory) FacesContextEx(com.ibm.xsp.context.FacesContextEx) DominoFacesContext(com.ibm.xsp.domino.context.DominoFacesContext) XPageSignerSessionFactory(org.openntf.domino.xsp.session.XPageSignerSessionFactory)

Example 3 with FacesContextEx

use of com.ibm.xsp.context.FacesContextEx in project org.openntf.xsp.jakartaee by OpenNTF.

the class AbstractXspLifecycleServlet method service.

@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setBufferSize(0);
    initializeSessionAsSigner();
    FacesContext facesContext = null;
    try {
        if (!initialized) {
            // initialization has do be done after NotesContext is initialized with session to support SessionAsSigner operations
            doInit(config);
            initialized = true;
        }
        facesContext = getFacesContext(request, response);
        FacesContextEx exc = (FacesContextEx) facesContext;
        ApplicationEx application = exc.getApplicationEx();
        this.doService(request, response, application);
    } catch (NoAccessSignal t) {
        throw t;
    } catch (Throwable t) {
        try (PrintWriter w = response.getWriter()) {
            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            XSPErrorPage.handleException(w, t, request.getRequestURL().toString(), false);
        } catch (javax.servlet.ServletException e) {
            throw new IOException(e);
        } catch (IllegalStateException e) {
            // Happens when the writer or output has already been opened
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
    } finally {
        if (facesContext != null) {
            releaseContext(facesContext);
        }
    }
}
Also used : ServletException(jakarta.servlet.ServletException) FacesContext(javax.faces.context.FacesContext) FacesContextEx(com.ibm.xsp.context.FacesContextEx) ApplicationEx(com.ibm.xsp.application.ApplicationEx) NoAccessSignal(com.ibm.xsp.acl.NoAccessSignal) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Aggregations

FacesContextEx (com.ibm.xsp.context.FacesContextEx)3 FacesContext (javax.faces.context.FacesContext)3 NoAccessSignal (com.ibm.xsp.acl.NoAccessSignal)1 ApplicationEx (com.ibm.xsp.application.ApplicationEx)1 DominoFacesContext (com.ibm.xsp.domino.context.DominoFacesContext)1 ServletException (jakarta.servlet.ServletException)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 XPageCurrentSessionFactory (org.openntf.domino.xsp.session.XPageCurrentSessionFactory)1 XPageSignerSessionFactory (org.openntf.domino.xsp.session.XPageSignerSessionFactory)1