You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Colin Rogers <Co...@objectconsulting.com.au> on 2013/11/27 01:57:51 UTC

ComponentRenderer

Wicketeers,

I have a problem when using ComponentRenderer in an actual live cycle. I assume it's not actually intended for this use, and hence the errors, but if I explain the issue, maybe someone can suggest an alternative or a workaround.

So... we have a set of 'pages' in a pageflow that update the main panel of a page with each button click - effectively a Wizard - but using our own component, rather than the standard one. Each step is updated via Ajax.

Our requirement - as odd as it is, is... we have a bunch of steps. We then eventually have a 'summary step'. For this step, we need to take a copy of the HTML, and render it to PDF, so in the next step, we can download a PDF version of the summary. The rendering of HTML to PDF is all fine, and saving as a resource - that all fine, too.

Basically - the error we end up with is an Ajax error - where the XML response is malformed. A fresh copy of the component/panel is returned, plus a second <ajaxResponse> tag that has a random page redirect. It's this second ajax response that is ultimately the issue.

We've tried adding code to onConfigure(), onBeforeRender() or onAfterRender() - we've also been cloneing the object (via WicketObjects) - with extra code not to repeat the method, etc.

I assume, because ComponentRenderer still uses the current 'live' response object, that two responses are being given, and the browser is then confused.

Is there anyway to either work round the issues above - using dummy requests, or is there another way to get the generated HTML via page cache or something else? I'm really open to any ideas! :)

Cheers,
Col.




EMAIL DISCLAIMER This email message and its attachments are confidential and may also contain copyright or privileged material. If you are not the intended recipient, you may not forward the email or disclose or use the information contained in it. If you have received this email message in error, please advise the sender immediately by replying to this email and delete the message and any associated attachments. Any views, opinions, conclusions, advice or statements expressed in this email message are those of the individual sender and should not be relied upon as the considered view, opinion, conclusions, advice or statement of this company except where the sender expressly, and with authority, states them to be the considered view, opinion, conclusions, advice or statement of this company. Every care is taken but we recommend that you scan any attachments for viruses.

Re: ComponentRenderer

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Wed, Nov 27, 2013 at 2:57 AM, Colin Rogers <
Colin.Rogers@objectconsulting.com.au> wrote:

> Wicketeers,
>
> I have a problem when using ComponentRenderer in an actual live cycle. I
> assume it's not actually intended for this use, and hence the errors, but
> if I explain the issue, maybe someone can suggest an alternative or a
> workaround.
>
> So... we have a set of 'pages' in a pageflow that update the main panel of
> a page with each button click - effectively a Wizard - but using our own
> component, rather than the standard one. Each step is updated via Ajax.
>
> Our requirement - as odd as it is, is... we have a bunch of steps. We then
> eventually have a 'summary step'. For this step, we need to take a copy of
> the HTML, and render it to PDF, so in the next step, we can download a PDF
> version of the summary. The rendering of HTML to PDF is all fine, and
> saving as a resource - that all fine, too.
>
> Basically - the error we end up with is an Ajax error - where the XML
> response is malformed. A fresh copy of the component/panel is returned,
> plus a second <ajaxResponse> tag that has a random page redirect. It's this
> second ajax response that is ultimately the issue.
>
> We've tried adding code to onConfigure(), onBeforeRender() or
> onAfterRender() - we've also been cloneing the object (via WicketObjects) -
> with extra code not to repeat the method, etc.
>
> I assume, because ComponentRenderer still uses the current 'live' response
> object, that two responses are being given, and the browser is then
> confused.
>

Your assumption is not correct.
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java?source=c#L59
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java?source=c#L93
For both #renderPage() and #renderComponent() Wicket creates a temporary
Response object for the rendering.

There must be another issue.


>
> Is there anyway to either work round the issues above - using dummy
> requests, or is there another way to get the generated HTML via page cache
> or something else? I'm really open to any ideas! :)
>
> Cheers,
> Col.
>
>
>
>
> EMAIL DISCLAIMER This email message and its attachments are confidential
> and may also contain copyright or privileged material. If you are not the
> intended recipient, you may not forward the email or disclose or use the
> information contained in it. If you have received this email message in
> error, please advise the sender immediately by replying to this email and
> delete the message and any associated attachments. Any views, opinions,
> conclusions, advice or statements expressed in this email message are those
> of the individual sender and should not be relied upon as the considered
> view, opinion, conclusions, advice or statement of this company except
> where the sender expressly, and with authority, states them to be the
> considered view, opinion, conclusions, advice or statement of this company.
> Every care is taken but we recommend that you scan any attachments for
> viruses.
>