Package javax.faces.application

Examples of javax.faces.application.StateManager


        }

        public void flushToWriter(Writer writer) throws IOException
        {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            StateManager stateManager = facesContext.getApplication().getStateManager();

            StringWriter stateWriter = new StringWriter();
            ResponseWriter realWriter = facesContext.getResponseWriter();
            facesContext.setResponseWriter(realWriter.cloneWithWriter(stateWriter));

            Object serializedView = stateManager.saveView(facesContext);

            stateManager.writeState(facesContext, serializedView);
            facesContext.setResponseWriter(realWriter);

            StringBuilder contentBuffer = getStringBuilder();
            String state = stateWriter.getBuffer().toString();
View Full Code Here


      }
 
      ResponseWriter oldResponseWriter = responseWriter;
      StringWriter stateAwareWriter = null;
     
      StateManager stateManager = context.getApplication().getStateManager();
      if (stateManager.isSavingStateInClient(context))
      {
          stateAwareWriter = new StringWriter();
 
          // Create a new response-writer using as an underlying writer the stateAwareWriter
          // Effectively, all output will be buffered in the stateAwareWriter so that later
          // this writer can replace the state-markers with the actual state.
          responseWriter = oldResponseWriter.cloneWithWriter(stateAwareWriter);
          context.setResponseWriter(responseWriter);
      }
 
      actuallyRenderView(context, view);
     
      if(oldResponseWriter != null)
      {
          context.setResponseWriter(oldResponseWriter);   
      }
 
      // We're done with the document - now we can write all content
      // to the response, properly replacing the state-markers on the way out
      // by using the stateAwareWriter
      if (stateManager.isSavingStateInClient(context))
      {
          flushBufferToWriter(stateAwareWriter.getBuffer(), externalContext.getResponseOutputWriter());
      }
      else
      {
          stateManager.saveView(context);
      }
     
      // now disable the ResponseSwitch again
      if (responseSwitch != null)
      {
View Full Code Here

  }
 
  protected void flushBufferToWriter(StringBuffer buff, Writer writer) throws IOException
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    StateManager stateManager = facesContext.getApplication().getStateManager();

    StringWriter stateWriter = new StringWriter();
    ResponseWriter realWriter = facesContext.getResponseWriter();
    facesContext.setResponseWriter(realWriter.cloneWithWriter(stateWriter));

    Object serializedView = stateManager.saveView(facesContext);

    stateManager.writeState(facesContext, serializedView);
    facesContext.setResponseWriter(realWriter);

    String state = stateWriter.getBuffer().toString();

    ExternalContext extContext = facesContext.getExternalContext();
View Full Code Here

            if (structureAndState.length == 2)
            {
                Object structureObj = structureAndState[0];
                Object stateObj = structureAndState[1];

                StateManager stateManager = context.getApplication().getStateManager();
                view = stateManager.new SerializedView(structureObj, stateObj);
            }
            else
            {
                throw new IOException("The state should be an array of Object[] of lenght 2");
View Full Code Here

    }

    ResponseWriter oldResponseWriter = responseWriter;
    StateMarkerAwareWriter stateAwareWriter = null;

    StateManager stateManager = facesContext.getApplication().getStateManager();
    if (stateManager.isSavingStateInClient(facesContext))
    {
      stateAwareWriter = new StateMarkerAwareWriter();

      // Create a new response-writer using as an underlying writer the stateAwareWriter
      // Effectively, all output will be buffered in the stateAwareWriter so that later
      // this writer can replace the state-markers with the actual state.
      responseWriter = hookInStateAwareWriter(
          oldResponseWriter, stateAwareWriter, renderKit, externalContext);
      facesContext.setResponseWriter(responseWriter);
    }

    actuallyRenderView(facesContext, viewToRender);

    facesContext.setResponseWriter(oldResponseWriter);

    //We're done with the document - now we can write all content
        //to the response, properly replacing the state-markers on the way out
        //by using the stateAwareWriter
    if (stateManager.isSavingStateInClient(facesContext))
    {
      stateAwareWriter.flushToWriter(response.getWriter());
    }
    else
    {
      stateManager.saveView(facesContext);
    }

    // Final step - we output any content in the wrappedResponse response from above to the response,
        // removing the wrappedResponse response from the request, we don't need it anymore
        ViewResponseWrapper afterViewTagResponse = (ViewResponseWrapper) externalContext.getRequestMap().get(
View Full Code Here

     * @param facesContext
     * @throws IOException
     */
    public void writeState(FacesContext facesContext) throws IOException
    {
    StateManager stateManager = facesContext.getApplication().getStateManager();
    if (stateManager.isSavingStateInClient(facesContext))
    {
        // Only write state marker if javascript view state is disabled
      ExternalContext extContext = facesContext.getExternalContext();
        if (!(JavascriptUtils.isJavascriptAllowed(extContext) && MyfacesConfig.getCurrentInstance(extContext).isViewStateJavascript())) {
          facesContext.getResponseWriter().write(FORM_STATE_MARKER);
        }
    }
    else
    {
      stateManager.writeState(facesContext, new Object[2]);
    }
  }
View Full Code Here

    }

        public void flushToWriter(Writer writer) throws IOException
        {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            StateManager stateManager = facesContext.getApplication().getStateManager();

            StringWriter stateWriter = new StringWriter();
            ResponseWriter realWriter = facesContext.getResponseWriter();
            facesContext.setResponseWriter(realWriter.cloneWithWriter(stateWriter));

            Object serializedView = stateManager.saveView(facesContext);

            stateManager.writeState(facesContext, serializedView);
            facesContext.setResponseWriter(realWriter);

            StringBuilder contentBuffer = getStringBuilder();
            String state = stateWriter.getBuffer().toString();
View Full Code Here

        }

        public void flushToWriter(Writer writer) throws IOException
        {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            StateManager stateManager = facesContext.getApplication().getStateManager();

            StringWriter stateWriter = new StringWriter();
            ResponseWriter realWriter = facesContext.getResponseWriter();
            facesContext.setResponseWriter(realWriter.cloneWithWriter(stateWriter));

            Object serializedView = stateManager.saveView(facesContext);

            stateManager.writeState(facesContext, serializedView);
            facesContext.setResponseWriter(realWriter);

            StringBuffer contentBuffer = getBuffer();
            StringBuffer state = stateWriter.getBuffer();
View Full Code Here

                if (structureAndState.length == 2)
                {
                    Object structureObj = structureAndState[0];
                    Object stateObj = structureAndState[1];

                    StateManager stateManager = context.getApplication().getStateManager();
                    view = stateManager.new SerializedView(structureObj, stateObj);
                }
                else
                {
                    throw new IOException("The state should be an array of Object[] of lenght 2");
View Full Code Here

            addChildParametersToHref(component, hrefBuf,
                                     false, //not the first url parameter
                                     writer.getCharacterEncoding());
        }

        StateManager stateManager = facesContext.getApplication().getStateManager();
        hrefBuf.append("&");
        if (stateManager.isSavingStateInClient(facesContext))
        {
            hrefBuf.append(URL_STATE_MARKER);
        }
        else
        {
View Full Code Here

TOP

Related Classes of javax.faces.application.StateManager

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.