The real question that has been asked time and time again on this list
when such a question is received is this:

WHY?  It's premature (and almost certainly unnecessary) optimization.
Doing it needlessly couples multiple components together - reducing
reuse.

As always, we are more than interested in seeing any results of
performance analysis that you have done that says that this will
reduce your page load time by any significant factor.

--
Jeremy Thomerson
http://www.wickettraining.com




On Wed, May 27, 2009 at 2:53 PM, J.-F. Rompre <jrom...@gmail.com> wrote:
>  I am trying to do something that should be easy to do, and may already be
>  available from the API (I am still usin 1.3.5).
>
>  How can one duplicate rendered strings?
>
>  In other words, I am trying to render once but copy a number of times for
>  better performance - e.g., putting a page navigator both at the top and
>  bottom of the list (the bottom is simply a label generated from copying the
>  rendered top one) or something more complex such as a calendar.
>
>  I tried using IBehavior.onRendered to copy getResponse.toString() for later
>  reuse, but myComponent.renderComponent() throws IllegalStateException: Page
>  not found - even though I am adding the component to a panel as instructed
>  by Component.renderComponent() - any ideas? My code is below.
>
>  I also thought of overriding one of the rendering methods to write directly
>  to the response, but Component.renderXXX() methods are all final - there
>  has to be a way to do this simply.
>
>  Any ideas?
>
>  Thanks!
>  JF
>
>  The containing panel java (groovy) code - 'ppn' is the component we want to
>  render only once
>  .....//ProductPanel
>  //...
>        productsContainer.add( products )
>         ProductsPagingNavigator ppn = new ProductsPagingNavigator(
>  "productsPagerTop", products)
>         ppn.add( new MakeRenderedStringBehavior())
>
>        productsContainer.add(  ppn)
>        ppn.renderComponent()       //THOWS 'Page not found..." exc.
>                   //save the rendering for reuse
>        CharSequence ppnOut = ppn.getRendered()
>                  //reuse it here
>        productsContainer.add new Label( "productsPagerBottom", ppnOut)
>  //....
>
>  //***********************************
>  The Behavior code attached to ppn above:
>  .....// MakeRenderedStringBehavior
>     //...
>    public void onRendered(final Component component)
>    {
>  //....
>            //  Copy the rendering if this component can store it..
>            CharSequence output = response.toString();
>            if ( component instanceof IRenderedString )
>                ((IRenderedString )component ).setRendered( output);
>            webResponse.write(output);
>        }
>  //....
>  //*************************************
>  The containing ProductPanel markup:
>  <wicket:panel
>  ....
>  <div class="Products" wicket:id="products" id=""
>    <div wicket:id="productsPagerTop" class="Navigation"</div <!--
>  rendered --
>    <ul
>        <li wicket:id="productsList" id=""
>             ...
>        </div</li
>    </ul
>    <div wicket:id="productsPagerBottom" class="Navigation"</div <!--
>  pasted in--
>  </div
>  </wicket:panel
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to