AW: Returning pure HTML using AjaxRequestTarget

2016-07-18 Thread Davids Patrick
rg/apache/wicket/request/http
> > /W
> > ebRequest.java#L45
> >
> > https://github.com/apache/wicket/blob/0ff4617437948f7eaabc6fc937af5b
> > 74
> > 5ccc5aba/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wic
> > ke
> > t-ajax-jquery.js#L579
> >
> > https://github.com/apache/wicket/blob/0ff4617437948f7eaabc6fc937af5b
> > 74
> > 5ccc5aba/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wic
> > ke
> > 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
> > > 
> > > 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
> > > >
>

AW: Returning pure HTML using AjaxRequestTarget

2016-07-18 Thread Davids Patrick
>
> 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 
> 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
> > 
> > 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ü

AW: Returning pure HTML using AjaxRequestTarget

2016-07-18 Thread Davids Patrick
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?





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 
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/0ff4617437948f7eaabc6fc937af5b745ccc5aba/wicket-request/src/main/java/org/apache/wicket/request/http/WebRequest.java#L45
https://github.com/apache/wicket/blob/0ff4617437948f7eaabc6fc937af5b745ccc5aba/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L579
https://github.com/apache/wicket/blob/0ff4617437948f7eaabc6fc937af5b745ccc5aba/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-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 
> 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.
> >
> >

AW: Returning pure HTML using AjaxRequestTarget

2016-07-18 Thread Davids Patrick
> 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.



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 
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/793d2cbaa97d6f2650b9f5ababb7e
> 46226c4b716/autocomplete-tagit-parent/autocomplete-tagit/src/main/java
> /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 
> 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

AW: Returning pure HTML using AjaxRequestTarget

2016-07-18 Thread Davids Patrick
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.

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/793d2cbaa97d6f2650b9f5ababb7e46226c4b716/autocomplete-tagit-parent/autocomplete-tagit/src/main/java/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 
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
>
>


AW: Returning pure HTML using AjaxRequestTarget

2016-07-18 Thread Davids Patrick
> 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/793d2cbaa97d6f2650b9f5ababb7e46226c4b716/autocomplete-tagit-parent/autocomplete-tagit/src/main/java/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 
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
>
>