You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Patrick Davids <pa...@nubologic.com> on 2015/04/15 11:02:51 UTC

Client side javascript listeners / HeaderItems / OnDomReadyHeaderItem

Hi all,

is there something included as feature in Wickets HeaderItems, what I 
can use as kind of client-side javascript observer-listener pattern?

For instance... I have components which relies on a on-dom-ready 
previous executed javascript, before the components internal javascripts 
can be executed.

So, its a kind of mix of PriorityHeaderItem and OnDomReadyHeaderItem and 
fire mechanism, when the scripts with priority has been successfully 
executed.

I would like to implement this feature as behavior, so multiple 
components on a page can have this pre-executed-javascript-behavior, and 
listen for a javascript "execution done" event.

This javascript-code should also applied to the page only once, 
independently how often the behavior is added to my different components 
on page.

I also need some sort of subscription code on javascript-side to get 
notified.


I already have some ideas to implement this, but would like to ask for 
framework-features or other inspirations, best practices or ideas, first.

Thanx for feedback!
Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Client side javascript listeners / HeaderItems / OnDomReadyHeaderItem

Posted by Patrick Davids <pa...@nubologic.com>.
Hi Andrea,
thanx for your feedback...

Currently I'm researching more into AbstractDefaultAjaxBehaviors.

My javascript which should be executed with priority is an ajax-call.
So, it can be handled by Wicket itself.

I've seen the default event of an AbstractDefaultAjaxBehavior is a 
'ondomready', so that fits my needs.
Also IAjaxCallListeners are looking very good to me, to have the 
listener-feature.

Right now I'm facing the problem, how I can force my behavior beeing a 
singleton on page, but appling many IAjaxCallListeners to the 
updateAjaxAttributes() to support a list of success-handlers.

Patrick

Am 15.04.2015 um 12:17 schrieb andrea del bene:
>
>
> On 15/04/2015 11:02, Patrick Davids wrote:
>> Hi all,
>>
>> is there something included as feature in Wickets HeaderItems, what I
>> can use as kind of client-side javascript observer-listener pattern?
>>
>> For instance... I have components which relies on a on-dom-ready
>> previous executed javascript, before the components internal
>> javascripts can be executed.
>>
>> So, its a kind of mix of PriorityHeaderItem and OnDomReadyHeaderItem
>> and fire mechanism, when the scripts with priority has been
>> successfully executed.
>>
>> I would like to implement this feature as behavior, so multiple
>> components on a page can have this pre-executed-javascript-behavior,
>> and listen for a javascript "execution done" event.
> Have considered yet to use resource dependencies. You might create a
> resource specifying which resource it depends on must be rendered first.
> Than you can render it in your custom behavior. See chapter '16.6
> Resource dependencies' of user guide.
>>
>> This javascript-code should also applied to the page only once,
>> independently how often the behavior is added to my different
>> components on page.
>>
>> I also need some sort of subscription code on javascript-side to get
>> notified.
>>
> To avoid multiple rendering of the same header item, class HeaderItem
> uses method getRenderTokens to check if the item has already been
> rendered. So if your heder item doesn't change (for example, the
> javascript code is always the same) it won't be rendered more than once.
>>
>> I already have some ideas to implement this, but would like to ask for
>> framework-features or other inspirations, best practices or ideas, first.
>>
>> Thanx for feedback!
>> Patrick
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Client side javascript listeners / HeaderItems / OnDomReadyHeaderItem

Posted by andrea del bene <an...@gmail.com>.

On 15/04/2015 11:02, Patrick Davids wrote:
> Hi all,
>
> is there something included as feature in Wickets HeaderItems, what I 
> can use as kind of client-side javascript observer-listener pattern?
>
> For instance... I have components which relies on a on-dom-ready 
> previous executed javascript, before the components internal 
> javascripts can be executed.
>
> So, its a kind of mix of PriorityHeaderItem and OnDomReadyHeaderItem 
> and fire mechanism, when the scripts with priority has been 
> successfully executed.
>
> I would like to implement this feature as behavior, so multiple 
> components on a page can have this pre-executed-javascript-behavior, 
> and listen for a javascript "execution done" event.
Have considered yet to use resource dependencies. You might create a 
resource specifying which resource it depends on must be rendered first. 
Than you can render it in your custom behavior. See chapter '16.6 
Resource dependencies' of user guide.
>
> This javascript-code should also applied to the page only once, 
> independently how often the behavior is added to my different 
> components on page.
>
> I also need some sort of subscription code on javascript-side to get 
> notified.
>
To avoid multiple rendering of the same header item, class HeaderItem 
uses method getRenderTokens to check if the item has already been 
rendered. So if your heder item doesn't change (for example, the 
javascript code is always the same) it won't be rendered more than once.
>
> I already have some ideas to implement this, but would like to ask for 
> framework-features or other inspirations, best practices or ideas, first.
>
> Thanx for feedback!
> Patrick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>