Re: Conditionally include header item when page contains ajax components
On Fri, Nov 15, 2013 at 9:18 AM, Martin Grigorov mgrigo...@apache.orgwrote: Hi, On Thu, Nov 14, 2013 at 10:43 PM, Nick Pratt nbpr...@gmail.com wrote: Understood. Martin - (for my own curiousity now) would it be possible and would there be any benefit to replacing the default Wicket jQuery resource reference with a custom veil.js ResourceReference that also included the packaged Wicket jquery resource ref as a dependency (i.e. configure this all in Application.init() )? Yes. This will work as well. getJavaScriptLibrarySettings().setWicketAjaxReference(veilJsThatDependsOnOriginalWicketAjaxReference) It's probably faster too... Nick On Thu, Nov 14, 2013 at 3:04 PM, Marios Skounakis msc...@gmail.com wrote: I probably wasn't clear enough. Here's my case: BasePage.renderHead() adds veil.js as javascript resource reference. All my pages inherit from BasePage. But veil.js is only useful when a page has wicket ajax. If I declare that veil.js has a dependency on jquery then the result is that all pages get both veil.js and jquery. What I want is that pages that don't have ajax (i.e. no Wicket-Ajax or Wicket-Event libraries) don't include veil.js. I could do it on a per component basis but this would be cumbersome and error prone. So instead I used Martin's solution and conditionally render veil.js only if the headerResponse renders Wicket-Event. On Thu, Nov 14, 2013 at 5:09 PM, Nick Pratt nbpr...@gmail.com wrote: Then you're doing something odd :-) If you have dependencies like this: CustomComponent -- Custom JS Reference (and this is added in the public void renderHead( Component component, IHeaderResponse response ) method) -- Wicket's JQuery JS Reference Page A (no Ajax components or components depending on Wicket's jquery ref) Page B -- CustomComponent (Page B being a copy of Page with a single instance of your CustomComponent) When you load Page A, the JS will not be loaded. When you load Page B, both the Wicket JS and the custom JS will be added to the page. If you are seeing Jquery being loaded in Page A then some component on that page requires the Wicket JS libraries and is causing it to be added. N On Thu, Nov 14, 2013 at 8:56 AM, Marios Skounakis msc...@gmail.com wrote: Thanks Martin, this worked well. Sebastien and Nick, I tried the solution with JQueryPluginResourceReference but this indeed caused JQuery to be loaded in non ajax pages. On Thu, Nov 14, 2013 at 3:04 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, You can create custom IHeaderResponseDecorator and by using custom IHeaderResponse you can check for contributions of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference See http://www.wicket-library.com/wicket-examples-6.0.x/resourceaggregation/?0 and http://wicketinaction.com/2012/07/wicket-6-resource-management/ On Thu, Nov 14, 2013 at 2:59 PM, Marios Skounakis msc...@gmail.com wrote: If I'm not mistaken this will cause JQuery to be included whenever my js reference is included. Effectively this will cause non-ajax pages to load javascript which applies only to ajax requests. What I want is the opposite: to not include my js reference when the page does not have any ajax. On Thu, Nov 14, 2013 at 2:04 PM, Sebastien seb...@gmail.com wrote: Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.com wrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Conditionally include header item when page contains ajax components
Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Re: Conditionally include header item when page contains ajax components
Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.com wrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Re: Conditionally include header item when page contains ajax components
oops, seems that one IMO is enough... On Thu, Nov 14, 2013 at 1:04 PM, Sebastien seb...@gmail.com wrote: Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.comwrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Re: Conditionally include header item when page contains ajax components
If I'm not mistaken this will cause JQuery to be included whenever my js reference is included. Effectively this will cause non-ajax pages to load javascript which applies only to ajax requests. What I want is the opposite: to not include my js reference when the page does not have any ajax. On Thu, Nov 14, 2013 at 2:04 PM, Sebastien seb...@gmail.com wrote: Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.com wrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Re: Conditionally include header item when page contains ajax components
Hi, You can create custom IHeaderResponseDecorator and by using custom IHeaderResponse you can check for contributions of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference See http://www.wicket-library.com/wicket-examples-6.0.x/resourceaggregation/?0 and http://wicketinaction.com/2012/07/wicket-6-resource-management/ On Thu, Nov 14, 2013 at 2:59 PM, Marios Skounakis msc...@gmail.com wrote: If I'm not mistaken this will cause JQuery to be included whenever my js reference is included. Effectively this will cause non-ajax pages to load javascript which applies only to ajax requests. What I want is the opposite: to not include my js reference when the page does not have any ajax. On Thu, Nov 14, 2013 at 2:04 PM, Sebastien seb...@gmail.com wrote: Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.com wrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Re: Conditionally include header item when page contains ajax components
The javascript will only be included if your Ajax enabled component is included that in turn references the JS ResourceReference, otherwise it wont be. N On Thu, Nov 14, 2013 at 7:59 AM, Marios Skounakis msc...@gmail.com wrote: If I'm not mistaken this will cause JQuery to be included whenever my js reference is included. Effectively this will cause non-ajax pages to load javascript which applies only to ajax requests. What I want is the opposite: to not include my js reference when the page does not have any ajax. On Thu, Nov 14, 2013 at 2:04 PM, Sebastien seb...@gmail.com wrote: Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.com wrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Re: Conditionally include header item when page contains ajax components
Then you're doing something odd :-) If you have dependencies like this: CustomComponent -- Custom JS Reference (and this is added in the public void renderHead( Component component, IHeaderResponse response ) method) -- Wicket's JQuery JS Reference Page A (no Ajax components or components depending on Wicket's jquery ref) Page B -- CustomComponent (Page B being a copy of Page with a single instance of your CustomComponent) When you load Page A, the JS will not be loaded. When you load Page B, both the Wicket JS and the custom JS will be added to the page. If you are seeing Jquery being loaded in Page A then some component on that page requires the Wicket JS libraries and is causing it to be added. N On Thu, Nov 14, 2013 at 8:56 AM, Marios Skounakis msc...@gmail.com wrote: Thanks Martin, this worked well. Sebastien and Nick, I tried the solution with JQueryPluginResourceReference but this indeed caused JQuery to be loaded in non ajax pages. On Thu, Nov 14, 2013 at 3:04 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, You can create custom IHeaderResponseDecorator and by using custom IHeaderResponse you can check for contributions of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference See http://www.wicket-library.com/wicket-examples-6.0.x/resourceaggregation/?0 and http://wicketinaction.com/2012/07/wicket-6-resource-management/ On Thu, Nov 14, 2013 at 2:59 PM, Marios Skounakis msc...@gmail.com wrote: If I'm not mistaken this will cause JQuery to be included whenever my js reference is included. Effectively this will cause non-ajax pages to load javascript which applies only to ajax requests. What I want is the opposite: to not include my js reference when the page does not have any ajax. On Thu, Nov 14, 2013 at 2:04 PM, Sebastien seb...@gmail.com wrote: Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.com wrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Re: Conditionally include header item when page contains ajax components
I probably wasn't clear enough. Here's my case: BasePage.renderHead() adds veil.js as javascript resource reference. All my pages inherit from BasePage. But veil.js is only useful when a page has wicket ajax. If I declare that veil.js has a dependency on jquery then the result is that all pages get both veil.js and jquery. What I want is that pages that don't have ajax (i.e. no Wicket-Ajax or Wicket-Event libraries) don't include veil.js. I could do it on a per component basis but this would be cumbersome and error prone. So instead I used Martin's solution and conditionally render veil.js only if the headerResponse renders Wicket-Event. On Thu, Nov 14, 2013 at 5:09 PM, Nick Pratt nbpr...@gmail.com wrote: Then you're doing something odd :-) If you have dependencies like this: CustomComponent -- Custom JS Reference (and this is added in the public void renderHead( Component component, IHeaderResponse response ) method) -- Wicket's JQuery JS Reference Page A (no Ajax components or components depending on Wicket's jquery ref) Page B -- CustomComponent (Page B being a copy of Page with a single instance of your CustomComponent) When you load Page A, the JS will not be loaded. When you load Page B, both the Wicket JS and the custom JS will be added to the page. If you are seeing Jquery being loaded in Page A then some component on that page requires the Wicket JS libraries and is causing it to be added. N On Thu, Nov 14, 2013 at 8:56 AM, Marios Skounakis msc...@gmail.com wrote: Thanks Martin, this worked well. Sebastien and Nick, I tried the solution with JQueryPluginResourceReference but this indeed caused JQuery to be loaded in non ajax pages. On Thu, Nov 14, 2013 at 3:04 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, You can create custom IHeaderResponseDecorator and by using custom IHeaderResponse you can check for contributions of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference See http://www.wicket-library.com/wicket-examples-6.0.x/resourceaggregation/?0 and http://wicketinaction.com/2012/07/wicket-6-resource-management/ On Thu, Nov 14, 2013 at 2:59 PM, Marios Skounakis msc...@gmail.com wrote: If I'm not mistaken this will cause JQuery to be included whenever my js reference is included. Effectively this will cause non-ajax pages to load javascript which applies only to ajax requests. What I want is the opposite: to not include my js reference when the page does not have any ajax. On Thu, Nov 14, 2013 at 2:04 PM, Sebastien seb...@gmail.com wrote: Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.com wrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Re: Conditionally include header item when page contains ajax components
Understood. Martin - (for my own curiousity now) would it be possible and would there be any benefit to replacing the default Wicket jQuery resource reference with a custom veil.js ResourceReference that also included the packaged Wicket jquery resource ref as a dependency (i.e. configure this all in Application.init() )? Nick On Thu, Nov 14, 2013 at 3:04 PM, Marios Skounakis msc...@gmail.com wrote: I probably wasn't clear enough. Here's my case: BasePage.renderHead() adds veil.js as javascript resource reference. All my pages inherit from BasePage. But veil.js is only useful when a page has wicket ajax. If I declare that veil.js has a dependency on jquery then the result is that all pages get both veil.js and jquery. What I want is that pages that don't have ajax (i.e. no Wicket-Ajax or Wicket-Event libraries) don't include veil.js. I could do it on a per component basis but this would be cumbersome and error prone. So instead I used Martin's solution and conditionally render veil.js only if the headerResponse renders Wicket-Event. On Thu, Nov 14, 2013 at 5:09 PM, Nick Pratt nbpr...@gmail.com wrote: Then you're doing something odd :-) If you have dependencies like this: CustomComponent -- Custom JS Reference (and this is added in the public void renderHead( Component component, IHeaderResponse response ) method) -- Wicket's JQuery JS Reference Page A (no Ajax components or components depending on Wicket's jquery ref) Page B -- CustomComponent (Page B being a copy of Page with a single instance of your CustomComponent) When you load Page A, the JS will not be loaded. When you load Page B, both the Wicket JS and the custom JS will be added to the page. If you are seeing Jquery being loaded in Page A then some component on that page requires the Wicket JS libraries and is causing it to be added. N On Thu, Nov 14, 2013 at 8:56 AM, Marios Skounakis msc...@gmail.com wrote: Thanks Martin, this worked well. Sebastien and Nick, I tried the solution with JQueryPluginResourceReference but this indeed caused JQuery to be loaded in non ajax pages. On Thu, Nov 14, 2013 at 3:04 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, You can create custom IHeaderResponseDecorator and by using custom IHeaderResponse you can check for contributions of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference See http://www.wicket-library.com/wicket-examples-6.0.x/resourceaggregation/?0 and http://wicketinaction.com/2012/07/wicket-6-resource-management/ On Thu, Nov 14, 2013 at 2:59 PM, Marios Skounakis msc...@gmail.com wrote: If I'm not mistaken this will cause JQuery to be included whenever my js reference is included. Effectively this will cause non-ajax pages to load javascript which applies only to ajax requests. What I want is the opposite: to not include my js reference when the page does not have any ajax. On Thu, Nov 14, 2013 at 2:04 PM, Sebastien seb...@gmail.com wrote: Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.com wrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios
Re: Conditionally include header item when page contains ajax components
Hi, On Thu, Nov 14, 2013 at 10:43 PM, Nick Pratt nbpr...@gmail.com wrote: Understood. Martin - (for my own curiousity now) would it be possible and would there be any benefit to replacing the default Wicket jQuery resource reference with a custom veil.js ResourceReference that also included the packaged Wicket jquery resource ref as a dependency (i.e. configure this all in Application.init() )? Yes. This will work as well. getJavaScriptLibrarySettings().setWicketAjaxReference(veilJsThatDependsOnOriginalWicketAjaxReference) Nick On Thu, Nov 14, 2013 at 3:04 PM, Marios Skounakis msc...@gmail.com wrote: I probably wasn't clear enough. Here's my case: BasePage.renderHead() adds veil.js as javascript resource reference. All my pages inherit from BasePage. But veil.js is only useful when a page has wicket ajax. If I declare that veil.js has a dependency on jquery then the result is that all pages get both veil.js and jquery. What I want is that pages that don't have ajax (i.e. no Wicket-Ajax or Wicket-Event libraries) don't include veil.js. I could do it on a per component basis but this would be cumbersome and error prone. So instead I used Martin's solution and conditionally render veil.js only if the headerResponse renders Wicket-Event. On Thu, Nov 14, 2013 at 5:09 PM, Nick Pratt nbpr...@gmail.com wrote: Then you're doing something odd :-) If you have dependencies like this: CustomComponent -- Custom JS Reference (and this is added in the public void renderHead( Component component, IHeaderResponse response ) method) -- Wicket's JQuery JS Reference Page A (no Ajax components or components depending on Wicket's jquery ref) Page B -- CustomComponent (Page B being a copy of Page with a single instance of your CustomComponent) When you load Page A, the JS will not be loaded. When you load Page B, both the Wicket JS and the custom JS will be added to the page. If you are seeing Jquery being loaded in Page A then some component on that page requires the Wicket JS libraries and is causing it to be added. N On Thu, Nov 14, 2013 at 8:56 AM, Marios Skounakis msc...@gmail.com wrote: Thanks Martin, this worked well. Sebastien and Nick, I tried the solution with JQueryPluginResourceReference but this indeed caused JQuery to be loaded in non ajax pages. On Thu, Nov 14, 2013 at 3:04 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, You can create custom IHeaderResponseDecorator and by using custom IHeaderResponse you can check for contributions of org.apache.wicket.ajax.WicketAjaxJQueryResourceReference See http://www.wicket-library.com/wicket-examples-6.0.x/resourceaggregation/?0 and http://wicketinaction.com/2012/07/wicket-6-resource-management/ On Thu, Nov 14, 2013 at 2:59 PM, Marios Skounakis msc...@gmail.com wrote: If I'm not mistaken this will cause JQuery to be included whenever my js reference is included. Effectively this will cause non-ajax pages to load javascript which applies only to ajax requests. What I want is the opposite: to not include my js reference when the page does not have any ajax. On Thu, Nov 14, 2013 at 2:04 PM, Sebastien seb...@gmail.com wrote: Hi Marios, IMO the best way IMO is to make your js reference extending JQueryPluginResourceReference (wicket 6) Best regards, Sebastien. On Thu, Nov 14, 2013 at 12:20 PM, Marios Skounakis msc...@gmail.com wrote: Hi all, I have a base page from which all my pages inherit. I want to conditionally include a javascript reference (header item) if the page contains an ajax component. The reference is a veil implementation based on BlockUI which is redundant (and also causes a javascript error) if the page has not ajax (and hence JQuery is not loaded). Any suggestions? Thanks Marios