Search in sources :

Example 1 with FacesUrlTransformer

use of org.jboss.weld.module.jsf.FacesUrlTransformer in project core by weld.

the class ConversationPropagationFilter method wrapResponse.

private ServletResponse wrapResponse(HttpServletResponse response, final String requestPath) {
    return new HttpServletResponseWrapper(response) {

        @Override
        public void sendRedirect(String path) throws IOException {
            FacesContext context = FacesContext.getCurrentInstance();
            if (context != null) {
                // this is a JSF request
                ConversationContext conversationContext = instance(contextId).select(HttpConversationContext.class).get();
                if (conversationContext.isActive()) {
                    Conversation conversation = conversationContext.getCurrentConversation();
                    if (!conversation.isTransient()) {
                        path = new FacesUrlTransformer(path, context).toRedirectViewId().toActionUrl().appendConversationIdIfNecessary(conversationContext.getParameterName(), conversation.getId()).encode();
                    }
                }
            }
            super.sendRedirect(path);
        }
    };
}
Also used : FacesContext(javax.faces.context.FacesContext) FacesUrlTransformer(org.jboss.weld.module.jsf.FacesUrlTransformer) HttpServletResponseWrapper(javax.servlet.http.HttpServletResponseWrapper) Conversation(javax.enterprise.context.Conversation) HttpConversationContext(org.jboss.weld.context.http.HttpConversationContext) ConversationContext(org.jboss.weld.context.ConversationContext) HttpConversationContext(org.jboss.weld.context.http.HttpConversationContext)

Aggregations

Conversation (javax.enterprise.context.Conversation)1 FacesContext (javax.faces.context.FacesContext)1 HttpServletResponseWrapper (javax.servlet.http.HttpServletResponseWrapper)1 ConversationContext (org.jboss.weld.context.ConversationContext)1 HttpConversationContext (org.jboss.weld.context.http.HttpConversationContext)1 FacesUrlTransformer (org.jboss.weld.module.jsf.FacesUrlTransformer)1