Search in sources :

Example 1 with ClientWindowAdapter

use of org.apache.deltaspike.jsf.impl.scope.window.ClientWindowAdapter in project deltaspike by apache.

the class JsfClientWindowAwareLifecycleWrapper method attachWindow.

@Override
public void attachWindow(FacesContext facesContext) {
    lazyInit();
    boolean delegateWindowHandling = ClientWindowConfig.ClientWindowRenderMode.DELEGATED.equals(clientWindowConfig.getClientWindowRenderMode(facesContext));
    if (delegateWindowHandling) {
        try {
            //the first wrapper is always DeltaSpikeLifecycleWrapper which can't extend from LifecycleWrapper
            Lifecycle externalWrapper = ((DeltaSpikeLifecycleWrapper) this.wrapped).getWrapped();
            delegateAttachWindow(facesContext, externalWrapper);
        } catch (Exception e) {
            try {
                attachWindowOnUnwrappedInstance(facesContext, this.wrapped);
            } catch (Exception e1) {
                throw ExceptionUtils.throwAsRuntimeException(e);
            }
        }
    } else {
        ClientWindow clientWindow = BeanProvider.getContextualReference(ClientWindow.class);
        //trigger init - might lead to a redirect -> response-complete
        String windowId = clientWindow.getWindowId(facesContext);
        if (!facesContext.getResponseComplete() && !"default".equals(windowId)) {
            facesContext.getExternalContext().setClientWindow(new ClientWindowAdapter(clientWindow));
        }
    }
}
Also used : ClientWindow(org.apache.deltaspike.jsf.spi.scope.window.ClientWindow) Lifecycle(javax.faces.lifecycle.Lifecycle) ClientWindowAdapter(org.apache.deltaspike.jsf.impl.scope.window.ClientWindowAdapter) FacesException(javax.faces.FacesException)

Aggregations

FacesException (javax.faces.FacesException)1 Lifecycle (javax.faces.lifecycle.Lifecycle)1 ClientWindowAdapter (org.apache.deltaspike.jsf.impl.scope.window.ClientWindowAdapter)1 ClientWindow (org.apache.deltaspike.jsf.spi.scope.window.ClientWindow)1