If tested it. It now looks like

WicketServlet.doGet
                // try to see if there is a redirect stored
                if (webApplication.getSettings().getRenderStrategy() ==
ApplicationSettings.REDIRECT_TO_BUFFER)
                {
                        // TODO should we test here for
                        // queryString.indexOf("IRedirectListener") ?
                        // only such urls should have a bufferedresponse.
                        String requestUri = servletRequest.getRequestURI();
                        if (servletRequest.getQueryString() != null)
                        {
                            requestUri += "?" + servletRequest.getQueryString();
                        }

                        BufferedResponse bufferedResponse =
webApplication.getBufferedResponse(servletRequest, requestUri);
                        if (bufferedResponse != null)
                        {
                                final WebResponse response = 
webApplication.newWebResponse(servletResponse);
                                response.write(bufferedResponse);
                                return;
                        }
                }

WebResponse

        /**
         * Write a buffered response to the output.
         *
         * @param bufferedResponse The buffered response to be returned
         * @throws IOException
         */
        public void write(final BufferedResponse bufferedResponse)
                throws IOException
        {
                // got a buffered response; now write it
                
getHttpServletResponse().setContentLength(bufferedResponse.getContentLength());
                
getHttpServletResponse().setContentType(bufferedResponse.getContentType());

                final OutputStream out = getOutputStream();
                try
                {
                        out.write(bufferedResponse.getBytes());
                }
                finally
                {
                        out.close();
                }
        }

It is a little bit less efficient because a WebResponse object will be
instanciated (which did not happen before), but I guess that doesn't
matter much. Now it is possible to subclass WebResponse and implement
whatever postprocessing you want to and it is all under your control

Juergen

On 11/9/05, Juergen Donnerstag <[EMAIL PROTECTED]> wrote:
> May be we should move the code from
> WicketServlet.doGet
> ...
>   if (RenderStrategy == REDIREC...)
>   {
>      this piece of code
>   }
>
> into WebRespone and make if like
>   if (RenderStrategy == REDIREC...)
>   {
>      final WebResponse response =
> webApplication.newWebResponse(servletResponse);
>      response.onRespondWithBufferedResponse();
>   }
>
> You are than able to call a postprocessor within your own WebResponse.
>
> Q.: why is redirectMap a variable of application and not a transient
> variable of session? redirectMap currently contains per Session data.
> Will the entry be removed from redirectMap if the session expires?
>
> Juergen
>
> On 11/9/05, Juergen Donnerstag <[EMAIL PROTECTED]> wrote:
> > IMO the name BufferedResponse is very much misleading. It should
> > better be something like TemporaryResponseBuffer or ResponseCache
> > maybe.
> >
> > Juergen
> >
> >
> > On 11/9/05, Juergen Donnerstag <[EMAIL PROTECTED]> wrote:
> > > Why do we have two BufferedResponse? What is the difference?
> > >
> > > Juergen
> > >
> > > On 11/9/05, Johan Compagner <[EMAIL PROTECTED]> wrote:
> > > > What i want is put some performance statistics in the page. (how long 
> > > > it did
> > > > take to render on the client and server side)
> > > > This means just a few lines of javascript one in the head and one at 
> > > > the end
> > > > of the file.
> > > >
> > > > I don't want to specify this javascript for all the html files (maybe i 
> > > > want
> > > > to turn it off)
> > > >
> > > > The first thought it it is simple just override:
> > > >    WebApplication.WebResponse newWebResponse(final HttpServletResponse
> > > > servletResponse)
> > > >     {
> > > >         return (getSettings().getBufferResponse()
> > > >                 ? new BufferedWebResponse(servletResponse)
> > > >                 : new WebResponse(servletResponse));
> > > >     }
> > > >
> > > > and return youre own version of the bufferedWebResponse that does some
> > > > parsing when close is called on it.
> > > >
> > > > This would work only that inside wicket we have the special
> > > > REDIRECT_TO_BUFFER and this makes
> > > > it own BufferedResponse where everything is streamed to. And the 
> > > > buffered
> > > > web response above is only used for the redirect url.
> > > >
> > > > Now i am thinking of change the 2 close() methods of the 2
> > > > Buffered(Web)Response classes that they call a postProcessor with there
> > > > buffer
> > > > Like this:
> > > >
> > > > public final void close()
> > > >     {
> > > >         if (stringBuffer == null)
> > > >         {
> > > >             throw new WicketRuntimeException("The response has already 
> > > > been
> > > > closed.");
> > > >         }
> > > >
> > > >         super.close();
> > > >
> > > >         stringBuffer = 
> > > > application.getPostProcessor().process(stringBuffer);
> > > > <<<<<<<<<<<<<
> > > >
> > > >         this.byteBuffer =
> > > > convertToCharset(getCharacterEncoding());
> > > >         this.stringBuffer = null;
> > > >     }
> > > >
> > > >
> > > >
> > > > Or we could make a  WebApplication.newBufferedREsponse()
> > > > (like newWebResponse())
> > > >
> > > > Currently it is just a bit strange that you can overwrite youre own
> > > > WebResponse but for the most part of wicket
> > > > that one won't be used for anything except sending a client side 
> > > > redirect.
> > > >
> > > > anybody a better idea?
> > > >
> > > > johan
> > > >
> > > >
> > >
> >
>


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to