no it is not possible and does not make sense to do so.

imagine you have a panel that renders <div id="1"><div id="2"></div></div>

not only would you have to rewrite the id of the top tag, but also of
the inner tags. this becomes even more complicated if components
output header contributors, eg javascript, that depends on those ids.

if you are instantiating components with the same state then you
should simply connect them all to the same state via models so the
state is reused and does not present overhead.

makes sense?

-igor

On Wed, May 27, 2009 at 5:03 PM, J.-F. Rompre <[email protected]> wrote:
> OK, thanks Martjin and Jeremy - I think mentioning performance was a mistake
> on my part..let me try again.
>
> I am not trying to couple different components, only to reuse what I know is
> never going to change within the same rendering - actually, avoiding the use
> of multiple component instances of the same subtype where a single instance
> would suffice.
>
> My question is: Is it possible to capture a rendered string for reuse? In
> other words, if I have a component subtype that I am currently instantiating
> multiple times with exactly the same state (therefore the output is exactly
> the same), is it possible to render it once and once only and reuse the
> string from that rendering within the same container or page?
>
> At this stage I am only trying to know how to do something instead of why
> (optimization or other reason, such as saving markup coding, or some other
> reason). I went through the source and searched on forums as well to find
> out, but didn't.
>
> My apologies if that question has been answered elsewhere - please let me
> know where I can look.
>
> Thanks,
>
> JF
>
> On Wed, May 27, 2009 at 6:33 PM, Jeremy Thomerson <[email protected]
>> wrote:
>
>> 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 <[email protected]> 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: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> --
> JF
> "Half the people you know are below average." -- Steven Wright
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to