Re: Wicket-Atmosphere complex JS

2012-11-20 Thread Pierre Goupil
Good afternoon,

I've created a Jira ticket with a quickstart. Here is the link:
https://issues.apache.org/jira/browse/WICKET-4869

Thanks a lot in advance.

Regards,

Pierre

-- 
Le bonheur n'est pas une destination, mais une façon de voyager.

Papa d'une petite Lou-Ann depuis le 30 juin.


Re: Wicket-Atmosphere complex JS

2012-11-19 Thread Pierre Goupil
Good evening,

So, I've tried what you said. I forgot one JS file in my initial attempt
but, even with this configuration I have now a different symptom. But it
still doesn't work. For now, the problem is that I have an empty
ajax-response!

Here is my code for the filter:

public class ResponseSizeFilter implements PerRequestBroadcastFilter
{
@Override
public BroadcastAction filter(final AtmosphereResource r, final Object
originalMessage,
final Object message)
{
final AtmosphereRequest request = r.getRequest();
if
(true.equalsIgnoreCase(request.getHeader(HeaderConfig.X_ATMOSPHERE_TRACKMESSAGESIZE)))
{
final String msg = message.toString();
return new BroadcastAction(BroadcastAction.ACTION.CONTINUE,
msg.length()
+ \r\n.length() + |);
}
return new BroadcastAction(BroadcastAction.ACTION.CONTINUE,
message);
}

@Override
public BroadcastAction filter(final Object originalMessage, final
Object message)
{
final String msg = message.toString();
return new BroadcastAction(BroadcastAction.ACTION.CONTINUE,
message);
}
}

I can see in my logs that it's called.

But whether I call the server-side by:

Wicket.Ajax.get({u: ${url}, e: click, c : blah})

or by:

jQuery('blah').wicketAtmosphere({url : ${url} });

It fails to update my component because the response is:

?xml version=1.0 encoding=UTF-8?ajax-response/ajax-response



The strange thing being that in my Filter, the message really contains the
right (non-empty) ajax-response!

Here is the Ajax / WebSocket managing code (it's in an
AbstractDefaultAjaxBehavior):

@Override
protected void respond(final AjaxRequestTarget target)
{
final CometChannel chan = new CometChannel(isTapped()));
Application.get().getEventBus().post(chan);
}

@Subscribe
public void rotate(final AjaxRequestTarget target, final CometChannel
event)
{
if (event.isTapped())
{
target.appendJavaScript(jQuery('#card + event.getUuid() +
').rotate(90););
}
else
{
target.appendJavaScript(jQuery('#card + event.getUuid() +
').rotate(0););
}
}

I thought that maybe the empty ajax-response came from the respond()
method not adding anything to the AjaxRequestTarget but in the examples
from Wicket GitHub, it's done like that for the chat message. So I ran out
of solutions.

As a side-note, this not the same code as in the original message, but the
symptom in this Comet channel is the same as here. The only difference
being that in this other channel, the message to broadcast is quite long,
hence the need for the BroadcastFilter.

So, is the idea of filing a Jira issue still valid?

Sorry for that long message. And thanks in advance for any help.

Regards,

Pierre Goupil

--
Le bonheur n'est pas une destination, mais une façon de voyager.

Papa d'une petite Lou-Ann depuis le 30 juin.


Re: Wicket-Atmosphere complex JS

2012-11-13 Thread Emond Papegaaij
This is most likely caused by incorrect escaping, which might be a bug in 
Wicket or Wicket-Atmosphere. Can you try to create a quickstart to demonstrate 
the problem and file a Jira ticket? You can use the example application at 
https://github.com/papegaaij/wicket-atmosphere-quickstart

Best regards,
Emond

On Sunday 11 November 2012 18:03:52 Pierre Goupil wrote:
 Hi all,
 
 When I submit complex JS to my client using target.appendJavaScript() with
 a @Subscribe method from Wicket-Atmosphere, I got this message in the
 browser console:
 
 Wicket.Ajax: Wicket.Ajax.Call.failure: Error while parsing response:
 Could not find root ajax-response element
 
 I do have an ajax-response tag and the response from the server seems to
 be all OK. Nonetheless, for a reason I'm not aware of, it fails.
 
 Did anyone encounter this error before? Is there a known work-around?
 
 When I have a simple response, it works though. The problem only occurs
 with complex responses.
 
 I'm using:
 
 wicket.version6.3.0-SNAPSHOT/wicket.version
 wicketstuff.version6.2.1/wicketstuff.version
 wicket-atmosphere.version0.5-SNAPSHOT/wicket-atmosphere.version
 
 (GIT master)
 
 Regards,
 
 Pierre

Re: Wicket-Atmosphere complex JS

2012-11-13 Thread Martin Grigorov
The problem is that Atmosphere sends the response in chunks.
Jean Francois explained in Atmosphere mailing lists that a special
Atmosphere has to be used that will collect the whole response before
flushing it.


On Tue, Nov 13, 2012 at 3:25 PM, Emond Papegaaij emond.papega...@topicus.nl
 wrote:

 This is most likely caused by incorrect escaping, which might be a bug in
 Wicket or Wicket-Atmosphere. Can you try to create a quickstart to
 demonstrate
 the problem and file a Jira ticket? You can use the example application at
 https://github.com/papegaaij/wicket-atmosphere-quickstart

 Best regards,
 Emond

 On Sunday 11 November 2012 18:03:52 Pierre Goupil wrote:
  Hi all,
 
  When I submit complex JS to my client using target.appendJavaScript()
 with
  a @Subscribe method from Wicket-Atmosphere, I got this message in the
  browser console:
 
  Wicket.Ajax: Wicket.Ajax.Call.failure: Error while parsing response:
  Could not find root ajax-response element
 
  I do have an ajax-response tag and the response from the server seems
 to
  be all OK. Nonetheless, for a reason I'm not aware of, it fails.
 
  Did anyone encounter this error before? Is there a known work-around?
 
  When I have a simple response, it works though. The problem only occurs
  with complex responses.
 
  I'm using:
 
  wicket.version6.3.0-SNAPSHOT/wicket.version
  wicketstuff.version6.2.1/wicketstuff.version
 
 wicket-atmosphere.version0.5-SNAPSHOT/wicket-atmosphere.version
 
  (GIT master)
 
  Regards,
 
  Pierre




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com http://jweekend.com/


Re: Wicket-Atmosphere complex JS

2012-11-13 Thread Emond Papegaaij
I found the link to the wiki page explaining how to fix this:
https://github.com/Atmosphere/atmosphere/wiki/Multiply-messages-arrives-as-
single-response-body-or-message-received-are-incomplete

It seems the trackMessageLength option needs to be enabled in the js, and some 
additional code is needed server side. From what I see, neither one will work 
without the other. Can you try if the solution provided at wiki works? To pass 
the additional option in the js, just copy jquery.wicketatmosphere.js, add the 
parameter and register the new file as a replacement resource in the 
application. Also please create a Jira issue for this. If you could post your 
findings there, that would help me tremendously, because my time to work on 
Wicket is very limited at the moment.

Best regards,
Emond

On Tuesday 13 November 2012 16:03:30 Martin Grigorov wrote:
 The problem is that Atmosphere sends the response in chunks.
 Jean Francois explained in Atmosphere mailing lists that a special
 Atmosphere has to be used that will collect the whole response before
 flushing it.
 
 
 On Tue, Nov 13, 2012 at 3:25 PM, Emond Papegaaij emond.papega...@topicus.nl
  wrote:
  
  This is most likely caused by incorrect escaping, which might be a bug in
  Wicket or Wicket-Atmosphere. Can you try to create a quickstart to
  demonstrate
  the problem and file a Jira ticket? You can use the example application at
  https://github.com/papegaaij/wicket-atmosphere-quickstart
  
  Best regards,
  Emond
  
  On Sunday 11 November 2012 18:03:52 Pierre Goupil wrote:
   Hi all,
   
   When I submit complex JS to my client using target.appendJavaScript()
  
  with
  
   a @Subscribe method from Wicket-Atmosphere, I got this message in the
   browser console:
   
   Wicket.Ajax: Wicket.Ajax.Call.failure: Error while parsing response:
   Could not find root ajax-response element
   
   I do have an ajax-response tag and the response from the server seems
  
  to
  
   be all OK. Nonetheless, for a reason I'm not aware of, it fails.
   
   Did anyone encounter this error before? Is there a known work-around?
   
   When I have a simple response, it works though. The problem only occurs
   with complex responses.
   
   I'm using:
   wicket.version6.3.0-SNAPSHOT/wicket.version
   wicketstuff.version6.2.1/wicketstuff.version
  
  wicket-atmosphere.version0.5-SNAPSHOT/wicket-atmosphere.version
  
   (GIT master)
   
   Regards,
   
   Pierre

Re: Wicket-Atmosphere complex JS

2012-11-13 Thread Pierre Goupil
Cheers, men, I'll try it ASAP!

Big thanks,

Pierre


On Tue, Nov 13, 2012 at 3:49 PM, Emond Papegaaij emond.papega...@topicus.nl
 wrote:

 I found the link to the wiki page explaining how to fix this:
 https://github.com/Atmosphere/atmosphere/wiki/Multiply-messages-arrives-as-
 single-response-body-or-message-received-are-incomplete

 It seems the trackMessageLength option needs to be enabled in the js, and
 some
 additional code is needed server side. From what I see, neither one will
 work
 without the other. Can you try if the solution provided at wiki works? To
 pass
 the additional option in the js, just copy jquery.wicketatmosphere.js, add
 the
 parameter and register the new file as a replacement resource in the
 application. Also please create a Jira issue for this. If you could post
 your
 findings there, that would help me tremendously, because my time to work on
 Wicket is very limited at the moment.

 Best regards,
 Emond

 On Tuesday 13 November 2012 16:03:30 Martin Grigorov wrote:
  The problem is that Atmosphere sends the response in chunks.
  Jean Francois explained in Atmosphere mailing lists that a special
  Atmosphere has to be used that will collect the whole response before
  flushing it.
 
 
  On Tue, Nov 13, 2012 at 3:25 PM, Emond Papegaaij 
 emond.papega...@topicus.nl
   wrote:
  
   This is most likely caused by incorrect escaping, which might be a bug
 in
   Wicket or Wicket-Atmosphere. Can you try to create a quickstart to
   demonstrate
   the problem and file a Jira ticket? You can use the example
 application at
   https://github.com/papegaaij/wicket-atmosphere-quickstart
  
   Best regards,
   Emond
  
   On Sunday 11 November 2012 18:03:52 Pierre Goupil wrote:
Hi all,
   
When I submit complex JS to my client using target.appendJavaScript()
  
   with
  
a @Subscribe method from Wicket-Atmosphere, I got this message in the
browser console:
   
Wicket.Ajax: Wicket.Ajax.Call.failure: Error while parsing response:
Could not find root ajax-response element
   
I do have an ajax-response tag and the response from the server
 seems
  
   to
  
be all OK. Nonetheless, for a reason I'm not aware of, it fails.
   
Did anyone encounter this error before? Is there a known work-around?
   
When I have a simple response, it works though. The problem only
 occurs
with complex responses.
   
I'm using:
wicket.version6.3.0-SNAPSHOT/wicket.version
wicketstuff.version6.2.1/wicketstuff.version
  
   wicket-atmosphere.version0.5-SNAPSHOT/wicket-atmosphere.version
  
(GIT master)
   
Regards,
   
Pierre




-- 
Le bonheur n'est pas une destination, mais une façon de voyager.

Papa d'une petite Lou-Ann depuis le 30 juin.