On Fri, Dec 12, 2014 at 11:38 AM, Martin Grigorov <mgrigo...@apache.org> wrote:
> I see it is a bit ugly, but oh well... this is how it works now.
>
> in YourComponent#renderHead():
>
> AtmosphereBehavior atmo =
> getPage().getBehaviors(AtmosphereBehavior.class).get(0);
> CharSequence callbackUrl = atmo.getCallbackUrl();
> headerResponse.render(OnDomReadyHeaderItem.forScript("Wicket.Ajax.get({u:
> "+callbackUrl+"})"));

Thanks, it works.
But I call whole atmo.renderHead(page, response); method.

>
> You may need to use some flag to make sure this happens once per page
> instance. Otherwise every re-render of such component will initialize a new
> web socket connection (or whatever fallback you may use)
>

Hmmm, do we really need this check if I call whole atmo.renderHead method?

Thanks for your help.

--
Daniel


> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Fri, Dec 12, 2014 at 11:36 AM, Daniel Stoch <daniel.st...@gmail.com>
> wrote:
>
>> Hi,
>>
>> Ok, I think I didn't described a problem well.
>>
>> When you add a component which subscribes some events, then
>> AtmosphereBehavior is added to page. But the wicketAtmosphere JS
>> callback is registered inside AtmosphereBehavior.renderHead() method,
>> so only (I think) when the whole page is rendered. When you add a
>> component using ajax, then this code (renderHead) is not called, so
>> events are not broadcasted to client: because page is not registered
>> in EventBus and does not have atmosphere resource assigned.
>>
>> So maybe my original question should be: how to invode this JS
>> callback from AtmosphereBehavior.renderHead in ajax requests?
>>
>> --
>> Daniel
>>
>> On Wed, Dec 10, 2014 at 12:19 PM, Daniel Stoch <daniel.st...@gmail.com>
>> wrote:
>> > Hi,
>> >
>> > It seems that I am using an older version of AtmosphereBehavior which
>> > implements IResourceListener. Since 6.17.0 this implementation was
>> > removed and the code is moved to onRequest() method.
>> > So I must check a newer version, maybe my problem is solved.
>> >
>> > Thanks for a tip!
>> >
>> > --
>> > Daniel
>> >
>> > On Wed, Dec 10, 2014 at 11:03 AM, Martin Grigorov <mgrigo...@apache.org>
>> wrote:
>> >> Hi,
>> >>
>> >> Please give more details.
>> >>
>> https://github.com/apache/wicket/blob/master/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereBehavior.java#L51
>> >> doesn't implement IResourceListener, so it seems you do something
>> custom.
>> >>
>> >> Just implementing IResourceListener doesn't mean anything to Wicket.
>> >> You need to create a callback url with
>> >>
>> org.apache.wicket.Component#urlFor(org.apache.wicket.RequestListenerInterface,
>> >> org.apache.wicket.request.mapper.parameter.PageParameters) and use it
>> >> somehow to invoke
>> org.apache.wicket.IResourceListener#onResourceRequested
>> >>
>> >>
>> >> Martin Grigorov
>> >> Wicket Training and Consulting
>> >> https://twitter.com/mtgrigorov
>> >>
>> >> On Wed, Dec 10, 2014 at 11:45 AM, Daniel Stoch <daniel.st...@gmail.com>
>> >> wrote:
>> >>
>> >>> Is it possible to invoke this listener manually, or maybe this is a
>> >>> generally a bad practise?
>> >>>
>> >>> --
>> >>> Daniel
>> >>>
>> >>> > On 9 gru 2014, at 12:24, Daniel Stoch <daniel.st...@gmail.com>
>> wrote:
>> >>> >
>> >>> > Hi,
>> >>> >
>> >>> > I have a behavior which implements IResourceListener
>> >>> > (AtmosphereBehavior). The problem is when this behavior is added to
>> >>> > page during ajax request (eg. some panel is dynamically added to
>> page)
>> >>> > - then onResourceRequested is not invoked for page. So when using
>> >>> > AtmosphereBehavior the suspended connection from the client is not
>> >>> > registered.
>> >>> >
>> >>> > How should I solve this problem: how and when call this
>> >>> > onResourceRequested method?
>> >>> >
>> >>> > --
>> >>> > Best regards,
>> >>> > Daniel
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> 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

Reply via email to