I think the fix for 6.13 will be something similar. The page should report that it is stateless no matter what components/behaviors it renders.
On Thu, Nov 21, 2013 at 1:33 PM, Mateusz Mieszkowski < mmieszkow...@objectivity.co.uk> wrote: > Just a quick update for those with the same problem: > Option 1 did not work as the page is not bookmarkable. > I used option 2 and override isBookmarkable() method in RenderPage to > return true. Page is set to stateless on its own. > > It's not too clean but in my case should be enough. Martin, please let me > know if you see any danger in such solution. > > Mateusz > > > -----Original Message----- > From: Martin Grigorov [mailto:mgrigo...@apache.org] > Sent: Thursday, November 21, 2013 10:56 AM > To: users@wicket.apache.org > Subject: Re: Rendering a component into a String > > Option 1) Override your component's onInitialize/onConfigure and call > page.setStatelessHint(true) > Option 2) Copy/paste ComponentRenderer.java locally and do something > similar directly in RenderPage > > > On Thu, Nov 21, 2013 at 11:29 AM, Mateusz Mieszkowski < > mmieszkow...@objectivity.co.uk> wrote: > > > Martin, > > > > Ticket created: https://issues.apache.org/jira/browse/WICKET-5422 > > Can you advise a workaround for now? > > > > Cheers, > > Mateusz > > > > > > -----Original Message----- > > From: Martin Grigorov [mailto:mgrigo...@apache.org] > > Sent: Thursday, November 21, 2013 9:49 AM > > To: users@wicket.apache.org > > Cc: Martin Dietze > > Subject: Re: Rendering a component into a String > > > > Please create a ticket. > > The page should be marked as stateless to avoid storing it. > > > > > > On Thu, Nov 21, 2013 at 10:40 AM, Mateusz Mieszkowski < > > mmieszkow...@objectivity.co.uk> wrote: > > > > > Hi guys, > > > > > > I noticed a problem with ComponentRenderer.renderComponent(). It is > > > possible that I'm missing something but this is what I get for now: > > > I'm using ComponenetRenderer withing CustomTooltipBehavior > > > (wicket-jquery-ui) to generate tooltip content. I add this to about > > > 50 rows in my table so I run renderComponent() method as many times. > > > All worked fine but there was a problem with performance when I used > > > Fragment component with markup attached to the WebPage. I did some > > > digging and finally checked > > > http://localhost:8080/context/wicket/internal/debug/diskDataStore > > > and it appeared that for one request, Wicket stores 51 pages in it. > > > All of the size of the whole page (about 300kB) and all of them > > > named org.apache.wicket.core.util.string.ComponentRenderer$RenderPage. > > > > > > I changed implementation from Fragment to Panel componenet and the > > > size was reduced to (1kB) but still all of these items were stored > > > in the DataStore. > > > > > > It seems that this method is creating a dummy page in order to > > > create the markup, but how can I avoid storing these pages? > > > > > > Best regards, > > > Mateusz > > > > > > -----Original Message----- > > > From: Martin Grigorov [mailto:mgrigo...@apache.org] > > > Sent: Wednesday, November 13, 2013 2:09 PM > > > To: users@wicket.apache.org; Martin Dietze > > > Subject: Re: Rendering a component into a String > > > > > > Hi, > > > > > > See the source of > > > http://www.wicket-library.com/wicket-examples-6.0.x/mailtemplate/?2e > > > xa > > > mple > > > > > > > > > On Wed, Nov 13, 2013 at 3:04 PM, Martin Dietze <d...@fh-wedel.de> wrote: > > > > > > > In a legacy project I've inherited I've got a piece of code that > > > > no longer works since the project was upgraded from Wicket 1.4 to > > > > Wicket 6. > > > > > > > > It's about rendering a component (a Wicket panel) into a string in > > > > order to return it wrapped into a webservice reply. > > > > > > > > The webservice is based on Wicket, too. The webservice is based on > > > > a Javascript handshake - the client calls the service using a > > > > token connecting the user to his current session he has on the > > > > application, the service replies are rendered into an iframe and > > > > deliver their data through postMessage. > > > > > > > > Thus, when rendering a reply, I am basically rendering a Wicket > > > > page within the context of my session. > > > > > > > > Now one of my API's calls requires me to render a Wicket panel > > > > into a String, which is then wrapped into JSON as part of the > > > > respective call's reply. > > > > > > > > The legacy code used to do this roughly like this (changes for > > > > using the Wicket 6 API were applied, but this nevertheless never > > > > worked): > > > > > > > > - create a mock RequestCycle by creating a MockHttpSession, a > > > > MockHttpServletRequest and a MockHttpServletResponse, glue > > > > this all together to obtain a ServletWebRequest and a > > > > BufferedWebResponse and finaly use use > > Application.createRequestCycle() > > > > to create the RequestCycle object > > > > > > > > - the component wrapped into a ComponentRenderingRequestHandler > > > > > > > > - then this code is executed: > > > > > > > > | try { > > > > | > > requestCycle.scheduleRequestHandlerAfterCurrent(requestHandler); > > > > | try { > > > > | if ( !requestCycle.processRequestAndDetach() ) { > > > > | > > > > | requestCycle.scheduleRequestHandlerAfterCurrent(new > > > > ErrorCodeRequestHandler((HttpServletResponse.SC_NOT_FOUND)); > > > > | } > > > > | } finally { > > > > | requestCycle.getResponse().close(); > > > > | } > > > > | return requestCycle.getResponse().toString(); > > > > | } finally { > > > > | requestCycle.detach(); > > > > | } > > > > > > > > I must admit I could not have written this myself :) > > > > > > > > Now when running this code, I run into two different > > > > exceptions: > > > > > > > > org.apache.wicket.WicketRuntimeException: Exception in rendering > > > > component: [Profile [Component id = profile]] > > > > at > > > > org.apache.wicket.Component.internalRenderComponent(Component.java > > > > :2 > > > > 57 > > > > 6) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:14 > > > > 93 > > > > ) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.Component.internalRender(Component.java:2379) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at org.apache.wicket.Component.render(Component.java:2307) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > [...] > > > > Caused by: java.lang.NullPointerException: null > > > > at > > > > org.apache.wicket.markup.html.internal.Enclosure.isVisible(Enclosu > > > > re > > > > .j > > > > ava:143) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.Component.determineVisibility(Component.java:436 > > > > 3) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.Component.internalBeforeRender(Component.java:91 > > > > 6) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.Component.beforeRender(Component.java:991) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.Component.internalPrepareForRender(Component.java: > > > > 22 > > > > 14) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at org.apache.wicket.Component.render(Component.java:2303) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java: > > > > 13 > > > > 90 > > > > ) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1 > > > > 55 > > > > 4) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupCon > > > > ta > > > > in > > > > er.java:1529) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContain > > > > er > > > > .j > > > > ava:1484) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy. > > > > on > > > > Co > > > > mponentTagBody(DefaultMarkupSourcingStrategy.java:71) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.Component.internalRenderComponent(Component.java > > > > :2 > > > > 54 > > > > 9) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > > > > > The enclosure's child component is null, as we see here: > > > > | @Override > > > > | public boolean isVisible() > > > > | { > > > > | return childComponent.determineVisibility() && > > > > super.isVisible(); > > > > | } > > > > > > > > Below that exception I find the markup of a stack trace page in my > > logs. > > > > Below that markup I get another stack trace: > > > > > > > > java.lang.NullPointerException: null > > > > at > > > > org.apache.wicket.Component.internalPrepareForRender(Component.java: > > > > 22 > > > > 24) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.Page.internalPrepareForRender(Page.java:241) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at org.apache.wicket.Component.render(Component.java:2303) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at org.apache.wicket.Page.renderPage(Page.java:1010) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.request.handler.render.WebPageRenderer.renderPag > > > > e( > > > > We > > > > bPageRenderer.java:121) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.request.handler.render.WebPageRenderer.respond(W > > > > eb > > > > Pa > > > > geRenderer.java:271) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.core.request.handler.RenderPageRequestHandler.re > > > > sp > > > > on > > > > d(RenderPageRequestHandler.java:165) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respo > > > > nd > > > > (R > > > > equestCycle.java:861) > > > > ~[wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.request.RequestHandlerStack.execute(RequestHandl > > > > er > > > > St > > > > ack.java:64) > > > > ~[wicket-request-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle. > > > > ja > > > > va > > > > :261) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.request.cycle.RequestCycle.processRequest(Reques > > > > tC > > > > yc > > > > le.java:218) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.request.cycle.RequestCycle.processRequestAndDeta > > > > ch > > > > (R > > > > equestCycle.java:289) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(W > > > > ic > > > > ke > > > > tFilter.java:259) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.protocol.http.WicketFilter.processRequest(Wicket > > > > Fi > > > > lt > > > > er.java:201) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > at > > > > org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter > > > > .j > > > > av > > > > a:282) > > > > [wicket-core-6.9.1.jar:6.9.1] > > > > > > > > Here the RequestCycle is null: > > > > | if (setRenderingFlag) > > > > | { > > > > | // only process feedback panel when we are about > > > > | to be > > > > rendered. > > > > | // setRenderingFlag is false in case > > > > | prepareForRender is > > > > called only to build component > > > > | // hierarchy (i.e. in > > > > BookmarkableListenerInterfaceRequestTarget). > > > > | // prepareForRender(true) is always called before > > > > | the > > > > actual rendering is done so > > > > | // that's where feedback panels gather the > > > > | messages > > > > | > > > > | List<Component> feedbacks = > > > > getRequestCycle().getMetaData(FEEDBACK_LIST); > > > > > > > > To me it seems like I've got two different problems here: > > > > > > > > - the component cannot be rendered because I'm doing something > > > > fundamentally wrong, thus I'm not getting the expected output > > > > > > > > - after the mock-RequestCycle's done with its work, there's no > > > > RequestCycle set anymore, thus I cannot render the reply > > > > > > > > > > > > I understand that my problem may be rather specific. And since > > > > this is webservice that is already in use, I cannot just rewrite > > > > it completely. Thus I would greatly appreciate any hint how i > > > > could accomplish what the old code used to do before the Wicket > upgrade? > > > > > > > > Cheers, > > > > > > > > M'bert > > > > > > > > -- > > > > ----------- / http://herbert.the-little-red-haired-girl.org / > > > > ------------- > > > > =+= > > > > Pilot: Call me a fuel truck. > > > > Tower: You're a fuel truck. > > > > > > > > ------------------------------------------------------------------ > > > > -- > > > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > > > > > > > > > > > -------------------------------------------------------------------- > > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >