Discussion:
Client side javascript listeners / HeaderItems / OnDomReadyHeaderItem
Patrick Davids
2015-04-15 09:02:51 UTC
Permalink
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-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
andrea del bene
2015-04-15 10:17:56 UTC
Permalink
Post by Patrick Davids
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.
Post by Patrick Davids
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.
Post by Patrick Davids
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
---------------------------------------------------------------------
Patrick Davids
2015-04-15 12:03:16 UTC
Permalink
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
Post by andrea del bene
Post by Patrick Davids
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.
Post by Patrick Davids
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.
Post by Patrick Davids
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-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org

Loading...