You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Edvin Syse <ed...@sysedata.no> on 2008/02/01 14:52:15 UTC
Can you control the order of contra added headercontributors?
Hi,
I have a basepage which adds a reference to jquery amongst other things
in its constructor via add(IHeaderContributor). Then I extend that
basepage in other pages.
If I want to add another javascript-reference that utilizes jquery in
the <wicket:head> tag of the childpage, I run into trouble because the
<wicket:head> tag is rendered before the headercontributors from the
basepage, hence the code fails because jquery is not yet loaded (this
happens for many jquery-addons if they are added before jquery.js).
Is there a way to tell Wicket that wicket:head should be rendered later
than the headercontributors or something, or can I in any way change the
order of what's added to the head section?
-- Edvin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can you control the order of contra added headercontributors?
Posted by Edvin Syse <ed...@sysedata.no>.
>>> can you not modify the version of jquery.js your designer is including
>>> to do such a check?
>> Yes I can. But how am I gonna sleep at night when my markup calls jquery.js two times? :))
> soundly?
Not a chance :)
>> Do you think my suggestion below is viable?
> maybe, but its also a pretty big hack...
> why dont you discuss with wicket-stuff jquery guys to see if they they
> are ok with it...
OK, I will create a working patch and ask them if they can live with it.
-- Edvin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can you control the order of contra added headercontributors?
Posted by Igor Vaynberg <ig...@gmail.com>.
On Feb 1, 2008 2:53 PM, Edvin Syse <ed...@sysedata.no> wrote:
> > i really dont get why the people packaging these libs together dont
> > provide a simple load_once check...
> >
> > can you not modify the version of jquery.js your designer is including
> > to do such a check?
>
> Yes I can. But how am I gonna sleep at night when my markup calls jquery.js two times? :))
soundly?
> Do you think my suggestion below is viable?
maybe, but its also a pretty big hack...
why dont you discuss with wicket-stuff jquery guys to see if they they
are ok with it...
-igor
>
> -- Edvin
>
>
> > -igor
> >
> >
> > On Feb 1, 2008 2:41 PM, Edvin Syse <ed...@sysedata.no> wrote:
> >>> That would still require me to do some code in every page they want to
> >>> use jquery stuff in. But what do you think of the possibility of the
> >>> JQuery headercontributor to "scan" the <wicket:head> section using a
> >>> regexp or something, and not add jquery if the regexp matches? Can I get
> >>> to the <wicket:head> stuff from a header-contributor?
> >> Somewhere along the lines of this, in JQueryBehaviour:
> >>
> >> public static final Pattern JQUERY_REGEXP = Pattern.compile("<script.*?src=\".*jquery.*\\.js>");
> >>
> >>
> >> public void renderHead(IHeaderResponse response) {
> >> super.renderHead(response);
> >> if(!JQUERY_REGEXP.matcher(response.getResponse().toString()).matches()) {
> >> response.renderJavascriptReference(JQUERY_JS);
> >> if (Application.DEVELOPMENT.equals(Application.get().getConfigurationType())) {
> >> response.renderJavascriptReference(JQUERY_DEBUG_JS);
> >> }
> >> }
> >> }
> >>
> >> .. or am I on the wrong track? :)
> >>
> >>
> >> -- Edvin
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
>
>
> ---------------------------------------------------------------------
> 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: Can you control the order of contra added headercontributors?
Posted by Edvin Syse <ed...@sysedata.no>.
> i really dont get why the people packaging these libs together dont
> provide a simple load_once check...
>
> can you not modify the version of jquery.js your designer is including
> to do such a check?
Yes I can. But how am I gonna sleep at night when my markup calls jquery.js two times? :)) Do you think my suggestion below is viable?
-- Edvin
> -igor
>
>
> On Feb 1, 2008 2:41 PM, Edvin Syse <ed...@sysedata.no> wrote:
>>> That would still require me to do some code in every page they want to
>>> use jquery stuff in. But what do you think of the possibility of the
>>> JQuery headercontributor to "scan" the <wicket:head> section using a
>>> regexp or something, and not add jquery if the regexp matches? Can I get
>>> to the <wicket:head> stuff from a header-contributor?
>> Somewhere along the lines of this, in JQueryBehaviour:
>>
>> public static final Pattern JQUERY_REGEXP = Pattern.compile("<script.*?src=\".*jquery.*\\.js>");
>>
>>
>> public void renderHead(IHeaderResponse response) {
>> super.renderHead(response);
>> if(!JQUERY_REGEXP.matcher(response.getResponse().toString()).matches()) {
>> response.renderJavascriptReference(JQUERY_JS);
>> if (Application.DEVELOPMENT.equals(Application.get().getConfigurationType())) {
>> response.renderJavascriptReference(JQUERY_DEBUG_JS);
>> }
>> }
>> }
>>
>> .. or am I on the wrong track? :)
>>
>>
>> -- Edvin
>>
>> ---------------------------------------------------------------------
>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can you control the order of contra added headercontributors?
Posted by Igor Vaynberg <ig...@gmail.com>.
i really dont get why the people packaging these libs together dont
provide a simple load_once check...
can you not modify the version of jquery.js your designer is including
to do such a check?
-igor
On Feb 1, 2008 2:41 PM, Edvin Syse <ed...@sysedata.no> wrote:
> > That would still require me to do some code in every page they want to
> > use jquery stuff in. But what do you think of the possibility of the
> > JQuery headercontributor to "scan" the <wicket:head> section using a
> > regexp or something, and not add jquery if the regexp matches? Can I get
> > to the <wicket:head> stuff from a header-contributor?
>
> Somewhere along the lines of this, in JQueryBehaviour:
>
> public static final Pattern JQUERY_REGEXP = Pattern.compile("<script.*?src=\".*jquery.*\\.js>");
>
>
> public void renderHead(IHeaderResponse response) {
> super.renderHead(response);
> if(!JQUERY_REGEXP.matcher(response.getResponse().toString()).matches()) {
> response.renderJavascriptReference(JQUERY_JS);
> if (Application.DEVELOPMENT.equals(Application.get().getConfigurationType())) {
> response.renderJavascriptReference(JQUERY_DEBUG_JS);
> }
> }
> }
>
> .. or am I on the wrong track? :)
>
>
> -- Edvin
>
> ---------------------------------------------------------------------
> 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: Can you control the order of contra added headercontributors?
Posted by Edvin Syse <ed...@sysedata.no>.
> That would still require me to do some code in every page they want to
> use jquery stuff in. But what do you think of the possibility of the
> JQuery headercontributor to "scan" the <wicket:head> section using a
> regexp or something, and not add jquery if the regexp matches? Can I get
> to the <wicket:head> stuff from a header-contributor?
Somewhere along the lines of this, in JQueryBehaviour:
public static final Pattern JQUERY_REGEXP = Pattern.compile("<script.*?src=\".*jquery.*\\.js>");
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
if(!JQUERY_REGEXP.matcher(response.getResponse().toString()).matches()) {
response.renderJavascriptReference(JQUERY_JS);
if (Application.DEVELOPMENT.equals(Application.get().getConfigurationType())) {
response.renderJavascriptReference(JQUERY_DEBUG_JS);
}
}
}
.. or am I on the wrong track? :)
-- Edvin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can you control the order of contra added headercontributors?
Posted by Edvin Syse <ed...@sysedata.no>.
> page.setmetadata(new jquery.includedKey(), true); their header
> contributor would omit the inclusion of the jquery.js. given that is a
That would still require me to do some code in every page they want to use jquery stuff in. But what do you think of the possibility of the
JQuery headercontributor to "scan" the <wicket:head> section using a regexp or something, and not add jquery if the regexp matches? Can I
get to the <wicket:head> stuff from a header-contributor?
-- Edvin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can you control the order of contra added headercontributors?
Posted by Igor Vaynberg <ig...@gmail.com>.
its not that it isnt "smart"...the problem here is that wicket:head
and iheadercontributor are two disjointed concepts, even though it
kinda looks like they do the same thing. all that wicket:head does is
collect markup and stick it into the head element, it doesnt know
whats inside - its just a string.
perhaps the jquery guys should make their stuff a little more
flexible...maybe if you do this
page.setmetadata(new jquery.includedKey(), true); their header
contributor would omit the inclusion of the jquery.js. given that is a
workaround, and a more general solution would be nicer...but that will
take quiet some thinking. feel free to add a jira issue so we can keep
track whenever one of us thinks of something clever/elegant for this.
-igor
On Feb 1, 2008 2:08 PM, Edvin Syse <ed...@sysedata.no> wrote:
> > if you put the reference to jquery into wicket:head of the base page
> > will it load before or after? then put only your initialization code
> > into a header contributor.
> > -igor
>
> That works up until you use wicketstuff-jquery in your app. Then JQuery is loaded via a headercontributor, and you end up loading two
> versions of jquery, which crashes your page :(
>
> I have tried to load jquery via <wicket:head> in the same way it is added via the headercontributor (path to resources/blablabla), but
> wicket doesn't "detect" it, and adds both the jquery from the wicketstuff-jquery-behaviour and the manual one..
>
> If the <wicket:head> renderer was "smart enough" to detect that the same file was added via a headercontributor I would be in business, but
> it doesn't :(
>
>
> -- Edvin
>
> ---------------------------------------------------------------------
> 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: Can you control the order of contra added headercontributors?
Posted by Edvin Syse <ed...@sysedata.no>.
> if you put the reference to jquery into wicket:head of the base page
> will it load before or after? then put only your initialization code
> into a header contributor.
> -igor
That works up until you use wicketstuff-jquery in your app. Then JQuery is loaded via a headercontributor, and you end up loading two
versions of jquery, which crashes your page :(
I have tried to load jquery via <wicket:head> in the same way it is added via the headercontributor (path to resources/blablabla), but
wicket doesn't "detect" it, and adds both the jquery from the wicketstuff-jquery-behaviour and the manual one..
If the <wicket:head> renderer was "smart enough" to detect that the same file was added via a headercontributor I would be in business, but
it doesn't :(
-- Edvin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can you control the order of contra added headercontributors?
Posted by Igor Vaynberg <ig...@gmail.com>.
if you put the reference to jquery into wicket:head of the base page
will it load before or after? then put only your initialization code
into a header contributor.
-igor
On Feb 1, 2008 12:54 PM, Edvin Syse <ed...@sysedata.no> wrote:
> > not sure we support that, or want to support it...
> > if you are using a headercontributor in one situation, why not use it
> > also in your child page?
> > -igor
>
> In my childpage, the head-section actually does more than just load the other javascript-file. It also does initialization for the
> jquery-components etc, like for example:
>
> $('#lang > li').hover(
> function () {
> $(this).find('ul').removeClass('collapsed');
> },
> function () {
> $(this).find('ul').addClass('collapsed');
> }
> );
>
> When my webdesigner needs to add stuff like that to a subpage, he can't add it to the head, because it will be rendered before jquery etc.
> Then, for every page he needs to do some jquery-magick in, I need to go:
>
> response.renderJavascriptReference(new ResourceReference(ThisSubPage.class, "extra-init-stuff-for-that-page.js"));
>
> .. in that particular page. And he needs to put the js-stuff in this separate file instead of the head of the subpage, where it belongs.
>
> It's OK for webdevelopers that does design/css themselves, but a real pain when you have designers working on your project.
>
> Can you think of a good solution for this given the current possibilities in Wicket?
>
> -- Edvin
>
>
>
> >
> >
> > On Feb 1, 2008 5:52 AM, Edvin Syse <ed...@sysedata.no> wrote:
> >> Hi,
> >>
> >> I have a basepage which adds a reference to jquery amongst other things
> >> in its constructor via add(IHeaderContributor). Then I extend that
> >> basepage in other pages.
> >>
> >> If I want to add another javascript-reference that utilizes jquery in
> >> the <wicket:head> tag of the childpage, I run into trouble because the
> >> <wicket:head> tag is rendered before the headercontributors from the
> >> basepage, hence the code fails because jquery is not yet loaded (this
> >> happens for many jquery-addons if they are added before jquery.js).
> >>
> >> Is there a way to tell Wicket that wicket:head should be rendered later
> >> than the headercontributors or something, or can I in any way change the
> >> order of what's added to the head section?
> >>
> >> -- Edvin
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
>
>
> ---------------------------------------------------------------------
> 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: Can you control the order of contra added headercontributors?
Posted by Edvin Syse <ed...@sysedata.no>.
> not sure we support that, or want to support it...
> if you are using a headercontributor in one situation, why not use it
> also in your child page?
> -igor
In my childpage, the head-section actually does more than just load the other javascript-file. It also does initialization for the
jquery-components etc, like for example:
$('#lang > li').hover(
function () {
$(this).find('ul').removeClass('collapsed');
},
function () {
$(this).find('ul').addClass('collapsed');
}
);
When my webdesigner needs to add stuff like that to a subpage, he can't add it to the head, because it will be rendered before jquery etc.
Then, for every page he needs to do some jquery-magick in, I need to go:
response.renderJavascriptReference(new ResourceReference(ThisSubPage.class, "extra-init-stuff-for-that-page.js"));
.. in that particular page. And he needs to put the js-stuff in this separate file instead of the head of the subpage, where it belongs.
It's OK for webdevelopers that does design/css themselves, but a real pain when you have designers working on your project.
Can you think of a good solution for this given the current possibilities in Wicket?
-- Edvin
>
>
> On Feb 1, 2008 5:52 AM, Edvin Syse <ed...@sysedata.no> wrote:
>> Hi,
>>
>> I have a basepage which adds a reference to jquery amongst other things
>> in its constructor via add(IHeaderContributor). Then I extend that
>> basepage in other pages.
>>
>> If I want to add another javascript-reference that utilizes jquery in
>> the <wicket:head> tag of the childpage, I run into trouble because the
>> <wicket:head> tag is rendered before the headercontributors from the
>> basepage, hence the code fails because jquery is not yet loaded (this
>> happens for many jquery-addons if they are added before jquery.js).
>>
>> Is there a way to tell Wicket that wicket:head should be rendered later
>> than the headercontributors or something, or can I in any way change the
>> order of what's added to the head section?
>>
>> -- Edvin
>>
>> ---------------------------------------------------------------------
>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can you control the order of contra added headercontributors?
Posted by Igor Vaynberg <ig...@gmail.com>.
not sure we support that, or want to support it...
if you are using a headercontributor in one situation, why not use it
also in your child page?
-igor
On Feb 1, 2008 5:52 AM, Edvin Syse <ed...@sysedata.no> wrote:
> Hi,
>
> I have a basepage which adds a reference to jquery amongst other things
> in its constructor via add(IHeaderContributor). Then I extend that
> basepage in other pages.
>
> If I want to add another javascript-reference that utilizes jquery in
> the <wicket:head> tag of the childpage, I run into trouble because the
> <wicket:head> tag is rendered before the headercontributors from the
> basepage, hence the code fails because jquery is not yet loaded (this
> happens for many jquery-addons if they are added before jquery.js).
>
> Is there a way to tell Wicket that wicket:head should be rendered later
> than the headercontributors or something, or can I in any way change the
> order of what's added to the head section?
>
> -- Edvin
>
> ---------------------------------------------------------------------
> 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