You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jlangston <jr...@gmail.com> on 2012/11/13 01:31:56 UTC

Wicket 6 event script tag and JavaScriptFilteredIntoFooterHeaderResponse

Wicket 6 has been very pleasant to work with thus far though I do have one
question someone might be able to help me with. When using a
HeaderResponseDecorator with JavaScriptFilteredIntoFooterHeaderResponse I am
curious why the script tag that contains all of the Wicket.Event.add
statements still gets put into the bucket in the head tag?  All the other
script tags seems to be moved into the footer appropriately.  If memory
serves me correctly it seems as though in wicket 6.0.0 it was funneled into
the footer JS bucket and has changed in more recent versions.  

If this was changed on purpose is there a reason I am missing for the
change?  

I am working on a jquery mobile web application with wicket 6 and would like
to leave the built in ajax link hijacking in place if possible but it won't
execute script tags in the head of pages that are loaded with ajax thus why
I am trying to get all the non global script tags to render in the footer
bucket so sub page updates will work properly.

If anyone has any feedback it would be much appreciated.
 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-event-script-tag-and-JavaScriptFilteredIntoFooterHeaderResponse-tp4653800.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket 6 event script tag and JavaScriptFilteredIntoFooterHeaderResponse

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Please show us your code.
This requirement works fine in my application.


On Tue, Nov 13, 2012 at 2:31 AM, jlangston <jr...@gmail.com> wrote:

> Wicket 6 has been very pleasant to work with thus far though I do have one
> question someone might be able to help me with. When using a
> HeaderResponseDecorator with JavaScriptFilteredIntoFooterHeaderResponse I
> am
> curious why the script tag that contains all of the Wicket.Event.add
> statements still gets put into the bucket in the head tag?  All the other
> script tags seems to be moved into the footer appropriately.  If memory
> serves me correctly it seems as though in wicket 6.0.0 it was funneled into
> the footer JS bucket and has changed in more recent versions.
>
> If this was changed on purpose is there a reason I am missing for the
> change?
>
> I am working on a jquery mobile web application with wicket 6 and would
> like
> to leave the built in ajax link hijacking in place if possible but it won't
> execute script tags in the head of pages that are loaded with ajax thus why
> I am trying to get all the non global script tags to render in the footer
> bucket so sub page updates will work properly.
>
> If anyone has any feedback it would be much appreciated.
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-6-event-script-tag-and-JavaScriptFilteredIntoFooterHeaderResponse-tp4653800.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Wicket 6 event script tag and JavaScriptFilteredIntoFooterHeaderResponse

Posted by jlangston <jr...@gmail.com>.
Thank you for sharing that snippet it solved the issue I was having. The only
thing I added was a check for PriorityHeaderItems to check the wrapped
HeaderItem. It's working very well. 

Thanks again.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-event-script-tag-and-JavaScriptFilteredIntoFooterHeaderResponse-tp4653800p4653890.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket 6 event script tag and JavaScriptFilteredIntoFooterHeaderResponse

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

My setup is a bit longer:

// this is the id of the HeaderResponseContainer in the end of the <body>
String JsInFooterFilterName = "jsInFooter";

setHeaderResponseDecorator(new IHeaderResponseDecorator {
      public IHeaderResponse decorate(IHeaderResponse response) {
        String headBucket = "headBucket";
        List<FilteringHeaderResponse.IHeaderResponseFilter> filters = new
ArrayList<FilteringHeaderResponse.IHeaderResponseFilter>();
        AbstractHeaderResponseFilter jsAcceptingFilter = new
AbstractHeaderResponseFilter(JsInFooterFilterName) {
          public boolean accepts(HeaderItem item) {
            return item instanceof JavaScriptHeaderItem  ||
                       item instanceof OnDomReadyHeaderItem ||
                       item instanceof OnLoadHeaderItem;
          }
        }
        filters.add(jsAcceptingFilter);
        OppositeHeaderResponseFilter nonJsFilter = new
OppositeHeaderResponseFilter(headBucket, jsAcceptingFilter);
        filters.add(nonJsFilter);

        return new FilteringHeaderResponse(response, headBucket, filters);
      }
    });



On Tue, Nov 13, 2012 at 10:43 PM, jlangston <jr...@gmail.com> wrote:

> Testing our application with wicket 6.0.0 it works that the event block is
> in
> the footer bucket but with wicket 6.2.0 it gets rendered in the head. I was
> able to see the same behavior using a quickstart on wicket 6.2.0.
>
> In the init method of WicketApplication I set the response decorator.
>
>     setHeaderResponseDecorator(new IHeaderResponseDecorator()
>     {
>       @Override
>       public IHeaderResponse decorate(IHeaderResponse response)
>       {
>         return new JavaScriptFilteredIntoFooterHeaderResponse(response,
> "footerJS");
>       }
>     });
>
> The Homepage class I simply set the footer bucket container and add an ajax
> link so it will add the event script tag and wicket event js reference.
>
> public class HomePage extends WebPage
> {
>   private static final long serialVersionUID = 1L;
>
>   public HomePage(final PageParameters parameters)
>   {
>     super(parameters);
>     add(new AjaxLink<Void>("alertTrigger")
>     {
>       private static final long serialVersionUID = -3848680946743570021L;
>
>       @Override
>       public void onClick(AjaxRequestTarget arg0)
>       {
>         arg0
>           .appendJavaScript("alert('View source and see the Event Script
> tag
> is in the header when it should get put in the footer')");
>       }
>     });
>     add(new HeaderResponseContainer("footerJs", "footerJS"));
>   }
> }
>
> In the html file
> Ajax Link
> <wicket:container wicket:id="footerJs"/>
>
>
> With this quickstart the jquery library reference, wicket-event.js and the
> script block for the events are  put in the header tag when all the other
> JS
> is correctly put into the footer bucket.
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-6-event-script-tag-and-JavaScriptFilteredIntoFooterHeaderResponse-tp4653800p4653850.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Wicket 6 event script tag and JavaScriptFilteredIntoFooterHeaderResponse

Posted by jlangston <jr...@gmail.com>.
Testing our application with wicket 6.0.0 it works that the event block is in
the footer bucket but with wicket 6.2.0 it gets rendered in the head. I was
able to see the same behavior using a quickstart on wicket 6.2.0.

In the init method of WicketApplication I set the response decorator. 

    setHeaderResponseDecorator(new IHeaderResponseDecorator()
    {
      @Override
      public IHeaderResponse decorate(IHeaderResponse response)
      {
        return new JavaScriptFilteredIntoFooterHeaderResponse(response,
"footerJS");
      }
    });

The Homepage class I simply set the footer bucket container and add an ajax
link so it will add the event script tag and wicket event js reference. 

public class HomePage extends WebPage
{
  private static final long serialVersionUID = 1L;

  public HomePage(final PageParameters parameters)
  {
    super(parameters);
    add(new AjaxLink<Void>("alertTrigger")
    {
      private static final long serialVersionUID = -3848680946743570021L;

      @Override
      public void onClick(AjaxRequestTarget arg0)
      {
        arg0
          .appendJavaScript("alert('View source and see the Event Script tag
is in the header when it should get put in the footer')");
      }
    });
    add(new HeaderResponseContainer("footerJs", "footerJS"));
  }
}

In the html file
Ajax Link 
<wicket:container wicket:id="footerJs"/>


With this quickstart the jquery library reference, wicket-event.js and the
script block for the events are  put in the header tag when all the other JS
is correctly put into the footer bucket.




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-event-script-tag-and-JavaScriptFilteredIntoFooterHeaderResponse-tp4653800p4653850.html
Sent from the Users forum mailing list archive at Nabble.com.

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