Package javax.faces.context

Examples of javax.faces.context.PartialResponseWriter


         * @param target the target component to be handled!
         */
        private void processRenderComponent(UIComponent target)
        {
            boolean inUpdate = false;
            PartialResponseWriter writer = (PartialResponseWriter) _facesContext.getResponseWriter();
            if (this._alreadyUpdatedComponents != null)
            {
                //Check if the parent was already updated.
                UIComponent parent = target;
                while (parent != null)
                {
                    if (this._alreadyUpdatedComponents.contains(parent))
                    {
                        return;
                    }
                    parent = parent.getParent();
                }
            }
            try
            {
                writer.startUpdate(target.getClientId(_facesContext));
                inUpdate = true;
                target.encodeAll(_facesContext);
            }
            catch (IOException ex)
            {
                Logger log = Logger.getLogger(PartialViewContextImpl.class.getName());
                if (log.isLoggable(Level.SEVERE))
                {
                    log.log(Level.SEVERE, "IOException for rendering component", ex);
                }
            }
            finally
            {
                if (inUpdate)
                {
                    try
                    {
                        writer.endUpdate();
                    }
                    catch (IOException ex)
                    {
                        Logger log = Logger.getLogger(PartialViewContextImpl.class.getName());
                        if (log.isLoggable(Level.SEVERE))
View Full Code Here


                "text/xml", encoding);
        }
        if (responseWriter instanceof PartialResponseWriter)  {
            return (PartialResponseWriter) responseWriter;
        } else {
            return new PartialResponseWriter(responseWriter);
        }

    }
View Full Code Here

                    comp.processValidators(ctx);
                } else if (curPhase == PhaseId.UPDATE_MODEL_VALUES) {
                    comp.processUpdates(ctx);
                } else if (curPhase == PhaseId.RENDER_RESPONSE) {

                    PartialResponseWriter writer = ctx.getPartialViewContext().getPartialResponseWriter();

                    writer.startUpdate(comp.getClientId(ctx));
                    try {
                        // do the default behavior...
                        comp.encodeAll(ctx);
                    }
                    catch (Exception ce) {
                        if (LOGGER.isLoggable(Level.SEVERE)) {
                            LOGGER.severe(ce.toString());
                        }
                        if (LOGGER.isLoggable(Level.FINE)) {
                            LOGGER.log(Level.FINE,
                            ce.toString(),
                            ce);
                        }
                    }
                    writer.endUpdate();
                }
                else {
                    throw new IllegalStateException("I18N: Unexpected " +
                                                    "PhaseId passed to " +
                                              " PhaseAwareContextCallback: " +
View Full Code Here

         try {

             ExternalContext extContext = context.getExternalContext();
             extContext.setResponseContentType("text/xml");
             extContext.addResponseHeader("Cache-Control", "no-cache");
             PartialResponseWriter writer = context.getPartialViewContext().getPartialResponseWriter();

             writer.startDocument();
             writer.startError(t.getClass().toString());
             if (t.getCause() != null) {
                 String msg = t.getCause().getMessage();
                 writer.write(((msg != null) ? msg : ""));
             } else {
                 String msg = t.getMessage();
                 writer.write(((msg != null) ? msg : ""));
                 writer.write(t.getMessage());
             }
             writer.endError();
             writer.endDocument();
             context.responseComplete();
         } catch (IOException ioe) {
            if (LOGGER.isLoggable(Level.SEVERE)) {
                LOGGER.log(Level.SEVERE,
                           ioe.toString(),
View Full Code Here

            // partial response writer.  We want to make sure that any content
            // or errors generated in the other phases are written using the
            // partial response writer.
            //
            if (phaseId == PhaseId.APPLY_REQUEST_VALUES) {
                PartialResponseWriter writer = pvc.getPartialResponseWriter();
                ctx.setResponseWriter(writer);
            }

        } else if (phaseId == PhaseId.RENDER_RESPONSE) {

            try {
                //
                // We re-enable response writing.
                //
                OnOffResponseWrapper onOffResponse = new OnOffResponseWrapper(ctx);
                onOffResponse.setEnabled(true);
                PartialResponseWriter writer = pvc.getPartialResponseWriter();
                ResponseWriter orig = ctx.getResponseWriter();
                ctx.getAttributes().put(ORIGINAL_WRITER, orig);
                ctx.setResponseWriter(writer);

                ExternalContext exContext = ctx.getExternalContext();
                exContext.setResponseContentType("text/xml");
                exContext.addResponseHeader("Cache-Control", "no-cache");
                writer.startDocument();
                if (isRenderAll()) {
                    renderAll(ctx, viewRoot);
                    renderState(ctx);
                    writer.endDocument();
                    return;
                }

                // Skip this processing if "none" is specified in the render list,
                // or there were no render phase client ids.
                if (renderIds == null || renderIds.isEmpty()) {
                } else {
                    processComponents(viewRoot, phaseId, renderIds, ctx);
                }

                renderState(ctx);

                writer.endDocument();
            } catch (IOException ex) {
                this.cleanupAfterView();
            } catch (RuntimeException ex) {
                this.cleanupAfterView();
                // Throw the exception
View Full Code Here

        // make sure to wrap the entire page in a <render> elemnt
        // with the special id of VIEW_ROOT_ID.  This is how the client
        // JavaScript knows how to replace the entire document with
        // this response.
        PartialViewContext pvc = context.getPartialViewContext();
        PartialResponseWriter writer = pvc.getPartialResponseWriter();
        writer.startUpdate(PartialResponseWriter.RENDER_ALL_MARKER);

        if (viewRoot.getChildCount() > 0) {
            for (UIComponent uiComponent : viewRoot.getChildren()) {
                uiComponent.encodeAll(context);
            }
        }

        writer.endUpdate();
    }
View Full Code Here

    private void renderState(FacesContext context) throws IOException {

        // Get the view state and write it to the response..
        PartialViewContext pvc = context.getPartialViewContext();
        PartialResponseWriter writer = pvc.getPartialResponseWriter();
        writer.startUpdate(PartialResponseWriter.VIEW_STATE_MARKER);
        String state = context.getApplication().getStateManager().getViewState(context);
        writer.write(state);
        writer.endUpdate();

    }
View Full Code Here

                "text/xml", encoding);
        }
        if (responseWriter instanceof PartialResponseWriter)  {
            return (PartialResponseWriter) responseWriter;
        } else {
            return new PartialResponseWriter(responseWriter);
        }

    }
View Full Code Here

                    comp.processValidators(ctx);
                } else if (curPhase == PhaseId.UPDATE_MODEL_VALUES) {
                    comp.processUpdates(ctx);
                } else if (curPhase == PhaseId.RENDER_RESPONSE) {

                    PartialResponseWriter writer = ctx.getPartialViewContext().getPartialResponseWriter();

                    writer.startUpdate(comp.getClientId(ctx));
                    try {
                        // do the default behavior...
                        comp.encodeAll(ctx);
                    }
                    catch (Exception ce) {
                        if (LOGGER.isLoggable(Level.SEVERE)) {
                            LOGGER.severe(ce.toString());
                        }
                        if (LOGGER.isLoggable(Level.FINE)) {
                            LOGGER.log(Level.FINE,
                            ce.toString(),
                            ce);
                        }
                    }
                    writer.endUpdate();
                }
                else {
                    throw new IllegalStateException("I18N: Unexpected " +
                                                    "PhaseId passed to " +
                                              " PhaseAwareContextCallback: " +
View Full Code Here

        FacesContext ctx = FacesContext.getCurrentInstance();
        getELFlash().doLastPhaseActions(ctx, true);

        if (ctx.getPartialViewContext().isPartialRequest()) {
            PartialResponseWriter pwriter;
            ResponseWriter writer = ctx.getResponseWriter();
            if (writer instanceof PartialResponseWriter) {
                pwriter = (PartialResponseWriter) writer;
            } else {
                pwriter = ctx.getPartialViewContext().getPartialResponseWriter();
            }
            setResponseContentType("text/xml");
            setResponseCharacterEncoding("UTF-8");
            addResponseHeader("Cache-Control", "no-cache");
            pwriter.startDocument();
            pwriter.redirect(requestURI);
            pwriter.endDocument();
        } else {
            ((HttpServletResponse) response).sendRedirect(requestURI);
        }
        ctx.responseComplete();
       
View Full Code Here

TOP

Related Classes of javax.faces.context.PartialResponseWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.