Here is what happens:
- you render some HTML from a *temporary* component, i.e. this component is
not member of the page's component tree
- your JS code to renders this HTML
- since there are <img> in the HTML additional HTTP calls are made to load
them
- the image could not be found because there is no such parent component

Consider using ImageResourceReference (from your other mail recently)
instead.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Jul 18, 2016 at 3:45 PM, Davids Patrick <p.dav...@healthag.de>
wrote:

> >Request#getClientUrl() is the base url. It is used to calculate relative
> urls.
> >ComponentRenderer.renderComponent() uses the current Request, so the url
> should be whatever you pass as wicket-ajax->baseurl
>
> Hmm... here an example...
> (The component, I render via ComponentRenderer.renderComponent() returns a
> list of images.)
> Those urls are broken...
>
> e.g.
>
> http://127.0.0.1:8888/myTest/wicket/page?188-IResourceListener-container-11-item-link-box-image
> &antiCache=1468849116540
>
> 2016-07-18 15:38:36,677 ERROR wicket.DefaultExceptionMapper - Unexpected
> error occurred
> org.apache.wicket.core.request.handler.ComponentNotFoundException:
> Component 'container:11:item:link:box:image' has been removed from page.
>         at
> org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:178)
> ~[wicket-core-6.22.0.jar:6.22.0]
>         at
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:890)
> ~[wicket-core-6.22.0.jar:6.22.0]
>         at
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
> ~[wicket-request-6.22.0.jar:6.22.0]
>         at
> org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
> [wicket-core-6.22.0.jar:6.22.0]
>         at
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
> [wicket-core-6.22.0.jar:6.22.0]
>         at
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
> [wicket-core-6.22.0.jar:6.22.0]
>         at
> org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
> [wicket-core-6.22.0.jar:6.22.0]
>         at
> org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
> [wicket-core-6.22.0.jar:6.22.0]
>         at
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
> [wicket-core-6.22.0.jar:6.22.0]
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
> [catalina.jar:7.0.62]
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> [catalina.jar:7.0.62]
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
> [catalina.jar:7.0.62]
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
> [catalina.jar:7.0.62]
>         at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
> [catalina.jar:7.0.62]
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
> [catalina.jar:7.0.62]
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
> [catalina.jar:7.0.62]
>         at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
> [catalina.jar:7.0.62]
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
> [catalina.jar:7.0.62]
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
> [catalina.jar:7.0.62]
>         at
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
> [tomcat-coyote.jar:7.0.62]
>         at
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
> [tomcat-coyote.jar:7.0.62]
>         at
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
> [tomcat-coyote.jar:7.0.62]
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> [?:1.7.0_79]
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> [?:1.7.0_79]
>         at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> [tomcat-coyote.jar:7.0.62]
>         at java.lang.Thread.run(Thread.java:745) [?:1.7.0_79]
>
>
>
>
> Health AG | Patrick Davids | Softwareentwickler
> Tel. +49 40 524 709-258 | p.dav...@healthag.de
> Fax +49 40 524 709-258 | www.healthag.de
>
>
> EOS Health Honorarmanagement AG | Lübeckertordamm 1–3 | 20099 Hamburg | AG
> Hamburg HRB 93806
> Vorstand | Jens Törper, Uwe Schäfer
> Aufsichtsratsvorsitzender | Klaus Engberding
>
> Save a tree – think before you print.
>
>
> -----Ursprüngliche Nachricht-----
> Von: Martin Grigorov [mailto:mgrigo...@apache.org]
> Gesendet: Montag, 18. Juli 2016 15:37
> An: users@wicket.apache.org
> Betreff: Re: Returning pure HTML using AjaxRequestTarget
>
> On Mon, Jul 18, 2016 at 3:28 PM, Davids Patrick <p.dav...@healthag.de>
> wrote:
>
> > Ok, got it.
> >
> > I think, the approach using the AjaxRequestTarget is wrong for my case.
> > My response is wrapped into xml which is used by wickets client side
> > ajax javascript, I think.
> >
> >
> > So, I think I will go back to the idea using
> > ComponentRender.renderComponent()
> >
> >
> > @Override
> > public void respond(final IRequestCycle requestCycle){
> >
> > WebResponse response = (WebResponse) requestCycle.getResponse();
> >
> > final String encoding =
> > Application.get().getRequestCycleSettings().getResponseRequestEncoding
> > (); response.setContentType("plan/html; charset=" + encoding);
> > response.disableCaching();
> >
> > response.write(ComponentRenderer.renderComponent(myComponent));
> > }
> >
> > Except the broken urls it is working quite ok.
> >
> > Any hint why those links are broken?
> >
>
> Request#getClientUrl() is the base url. It is used to calculate relative
> urls.
> ComponentRenderer.renderComponent() uses the current Request, so the url
> should be whatever you pass as wicket-ajax-baseurl
>
>
> >
> >
> >
> >
> >
> > Health AG | Patrick Davids | Softwareentwickler Tel. +49 40 524
> > 709-258 | p.dav...@healthag.de Fax +49 40 524 709-258 |
> > www.healthag.de
> >
> >
> > EOS Health Honorarmanagement AG | Lübeckertordamm 1–3 | 20099 Hamburg
> > | AG Hamburg HRB 93806 Vorstand | Jens Törper, Uwe Schäfer
> > Aufsichtsratsvorsitzender | Klaus Engberding
> >
> > Save a tree – think before you print.
> >
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Martin Grigorov [mailto:mgrigo...@apache.org]
> > Gesendet: Montag, 18. Juli 2016 14:42
> > An: users@wicket.apache.org
> > Betreff: Re: Returning pure HTML using AjaxRequestTarget
> >
> > On Mon, Jul 18, 2016 at 2:37 PM, Davids Patrick <p.dav...@healthag.de>
> > wrote:
> >
> > > > How do you make the request ?
> > > I create the url by calling my AbstractDefaultAjaxBehavior instance
> > > .getCallbackUrl().
> > > I put into a particular link and the javascript (I try to integrate)
> > > executes the link.
> > >
> > >
> > > Now, I try to add it like this:
> > > getCallbackUrl().toString()+"&wicket-ajax=true";
> > >
> > > Then I run into Bad request errors, wicket base url or something is
> > > missing.
> > >
> >
> > You need one more parameter:
> >
> > https://github.com/apache/wicket/blob/0ff4617437948f7eaabc6fc937af5b74
> > 5ccc5aba/wicket-request/src/main/java/org/apache/wicket/request/http/W
> > ebRequest.java#L45
> >
> > https://github.com/apache/wicket/blob/0ff4617437948f7eaabc6fc937af5b74
> > 5ccc5aba/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicke
> > t-ajax-jquery.js#L579
> >
> > https://github.com/apache/wicket/blob/0ff4617437948f7eaabc6fc937af5b74
> > 5ccc5aba/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicke
> > t-ajax-jquery.js#L83
> >
> >
> > >
> > >
> > >
> > > Health AG | Patrick Davids | Softwareentwickler Tel. +49 40 524
> > > 709-258 | p.dav...@healthag.de Fax +49 40 524 709-258 |
> > > www.healthag.de
> > >
> > >
> > > EOS Health Honorarmanagement AG | Lübeckertordamm 1–3 | 20099
> > > Hamburg
> > > | AG Hamburg HRB 93806 Vorstand | Jens Törper, Uwe Schäfer
> > > Aufsichtsratsvorsitzender | Klaus Engberding
> > >
> > > Save a tree – think before you print.
> > >
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Martin Grigorov [mailto:mgrigo...@apache.org]
> > > Gesendet: Montag, 18. Juli 2016 14:28
> > > An: users@wicket.apache.org
> > > Betreff: Re: Returning pure HTML using AjaxRequestTarget
> > >
> > > On Mon, Jul 18, 2016 at 2:18 PM, Davids Patrick
> > > <p.dav...@healthag.de>
> > > wrote:
> > >
> > > > Ok... the problem seem to be isAjax() == false.
> > > > Hmm... but I'm not able to add a parameter to the request, which
> > > > let
> > > > isAjax() becoming true, which falls through forcing
> > > > shouldRedirectToPage() returning false.
> > > >
> > >
> > > Why not?
> > > How do you make the request ?
> > >
> > >
> > > >
> > > > private boolean shouldRedirectToPage(IRequestCycle requestCycle) {
> > > > if
> > > > (responseObject.containsPage()) { return true; }
> > > >
> > > > if (((WebRequest)requestCycle.getRequest()).isAjax() == false) {
> > > > // the request was not sent by wicket-ajax.js - this can happen
> > > > when an Ajax request was // intercepted with
> > > > #redirectToInterceptPage() and then the original request is
> > > > re-sent // by the browser on a subsequent
> > > > #continueToOriginalDestination() return true; }
> > > >
> > > > return false;
> > > > }
> > > >
> > > >
> > > > Health AG | Patrick Davids | Softwareentwickler Tel. +49 40 524
> > > > 709-258 | p.dav...@healthag.de Fax +49 40 524 709-258 |
> > > > www.healthag.de
> > > >
> > > >
> > > > EOS Health Honorarmanagement AG | Lübeckertordamm 1–3 | 20099
> > > > Hamburg
> > > > | AG Hamburg HRB 93806 Vorstand | Jens Törper, Uwe Schäfer
> > > > Aufsichtsratsvorsitzender | Klaus Engberding
> > > >
> > > > Save a tree – think before you print.
> > > >
> > > >
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: Davids Patrick [mailto:p.dav...@healthag.de]
> > > > Gesendet: Montag, 18. Juli 2016 13:50
> > > > An: users@wicket.apache.org
> > > > Cc: mgrigo...@apache.org
> > > > Betreff: AW: Returning pure HTML using AjaxRequestTarget
> > > >
> > > > > If you add a Page to AjaxRequestTarget then Wicket will produce
> > > > > a
> > > > redirect Ajax response.
> > > >
> > > > I don't do that. Just adding a single component.
> > > >
> > > >
> > > > > You can use getResponse().write(...) to write raw response instead.
> > > > This was my first try in combination with
> > > > ComponentRenderer.renderComponent(myComponent).
> > > > But I get problems with urls. Some image urls are broken with
> > > > "ComponentNotFoundExceptions".
> > > > renderComponent(myComponent) also writing logs, its not a good
> > > > idea, what I'm doing. ;-) So I changed my implementation to the
> > > > current way using AjaxRequestTarget.
> > > >
> > > >
> > > > Patrick
> > > >
> > > >
> > > >
> > > > Health AG | Patrick Davids | Softwareentwickler Tel. +49 40 524
> > > > 709-258 | p.dav...@healthag.de Fax +49 40 524 709-258 |
> > > > www.healthag.de
> > > >
> > > >
> > > > EOS Health Honorarmanagement AG | Lübeckertordamm 1–3 | 20099
> > > > Hamburg
> > > > | AG Hamburg HRB 93806 Vorstand | Jens Törper, Uwe Schäfer
> > > > Aufsichtsratsvorsitzender | Klaus Engberding
> > > >
> > > > Save a tree – think before you print.
> > > >
> > > >
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: Martin Grigorov [mailto:mgrigo...@apache.org]
> > > > Gesendet: Montag, 18. Juli 2016 13:29
> > > > An: users@wicket.apache.org
> > > > Betreff: Re: Returning pure HTML using AjaxRequestTarget
> > > >
> > > > Hi,
> > > >
> > > > If you add a Page to AjaxRequestTarget then Wicket will produce a
> > > > redirect Ajax response.
> > > >
> > > > I am not sure how far you can go with AjaxRequestTarget#add() though.
> > > > You can use getResponse().write(...) to write raw response instead.
> > > > Or schedule another IRequestHandler to render the response, as in
> > > > https://github.com/wicketstuff/core/blob/793d2cbaa97d6f2650b9f5aba
> > > > bb
> > > > 7e
> > > > 46226c4b716/autocomplete-tagit-parent/autocomplete-tagit/src/main/
> > > > ja va /org/wicketstuff/tagit/TagItAjaxBehavior.java#L50
> > > >
> > > > Martin Grigorov
> > > > Wicket Training and Consulting
> > > > https://twitter.com/mtgrigorov
> > > >
> > > > On Mon, Jul 18, 2016 at 1:16 PM, Davids Patrick
> > > > <p.dav...@healthag.de>
> > > > wrote:
> > > >
> > > > > Hi all,
> > > > > I'm working on a integration of a javascript which does html
> > > > > replacements by itself.
> > > > >
> > > > > So, it expects pure HTML and what I try to achieve is, becoming
> > > > > wicket returning the HTML via AjaxRequest.add(...).
> > > > >
> > > > > I've seen the methods setDataType("html") and
> > > > > setWicketAjaxResponse(false) of AjaxRequestAttributes.
> > > > > I thought this would be the solution. Just getting a html
> > > > > snippet not processed by wickets client-side ajax features.
> > > > >
> > > > > My problem now is, I don't get a html part, but an redirect 302
> > > > > pointing to a url which returns the entire webpage.
> > > > >
> > > > > Where does this 302 come from?
> > > > > And why does it point the page url?
> > > > > How can I change that behavior, so just returning the html
> > > > > snippets of components added to the AjaxRequestTarget?
> > > > >
> > > > > Thanx for help!
> > > > > kind regards
> > > > > Patrick
> > > > >
> > > > > Health AG | Patrick Davids | Softwareentwickler Tel. +49 40 524
> > > > > 709-258 | p.dav...@healthag.de Fax +49 40 524 709-258 |
> > > > > www.healthag.de
> > > > >
> > > > >
> > > > > EOS Health Honorarmanagement AG | Lübeckertordamm 1–3 | 20099
> > > > > Hamburg
> > > > > | AG Hamburg HRB 93806 Vorstand | Jens Törper, Uwe Schäfer
> > > > > Aufsichtsratsvorsitzender | Klaus Engberding
> > > > >
> > > > > Save a tree – think before you print.
> > > > >
> > > > >
> > > > >
> > > > > ----------------------------------------------------------------
> > > > > --
> > > > > --
> > > > > - 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
> >
> >
>

Reply via email to