Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8968433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:27:10+00:00 2026-06-15T17:27:10+00:00

With the following code, I add trackingpixel to some page page.html by overriding the

  • 0

With the following code, I add trackingpixel to some page page.html by overriding the method renderHead(Component component, IHeaderResponse response). This works fine.

page.html looks like this:

    <!doctype html>
    <html xmlns:wicket="http://wicket.apache.org/">
    <head>
    ..
    <wicket:container wicket:id="header"></wicket:container>
    </head>
    <body>
      ..
 <script wicket:id="scriptHolder" type="text/javascript" > I would like to add my script here 
</script>
..
    </body>
    </html>

TrackingPixel.java:

    public abstract class TrackingPixel extends AbstractDefaultAjaxBehavior {

            protected TrackingPixel(TrackingPixelType type) {
           ..
        }


        @Override
        public void renderHead(Component component, IHeaderResponse response) {
                response.renderOnDomReadyJavaScript("WebtrekkInstance = {
                 ..   
                             'path' : 'anyPath',
                     ...:...
                                  ..
                };
");
        }     
             }

renderHead-method adds a trackingpixel to the main page. Right mouse click on the page -> source code shows that the following script is added to the page:

<script type="text/javascript" >

Wicket.Event.add(window, "domready", function(event) {      
            WebtrekkInstance = {
             ..   
                         'path' : 'anyPath',
                 ...:...
                              ..
            };
                        ..            
            ;});
</script>

Now I would like to add trackingpixel to a popup. My problem is that I can’t add a script to the body. The method renderHead(Component component, IHeaderResponse response) doesn’t do that, because (I guess) the popup pops up on the same page, so there is only one head and it will not render twice. So I tried to do this with WebMarkupContainer as you can see below.

OurServicePopup.java

/**
 * Class to display our service as popup
 */
public class OurServicePopupPage<T> extends WebPage {

    public OurServicePopupPage(PageParameters parameters) {
        super(parameters);
    }

    @Override
    protected void onInitialize() {
        add(new OurServicePixel());
        super.onInitialize();
    }      
}

OurServicePixel.java looks like this:

  public class OurServicePopupPixel extends TrackingPixel{
                public OurServicePopupPixel() {
                        }

                WebMarkupContainer scriptContainer = new WebMarkupContainer("scriptContainer");
                @Override
                public void renderHead(Component component, IHeaderResponse response) {   
                    scriptContainer.add(new AttributeAppender("type", Model.of("text/javascript")));
                    scriptContainer.add(
                        new AttributeAppender("src","WebtrekkInstance = {
                 ..   
                             'path' : 'anyPath',
                     ...:...
                                  ..
                };
");

          }
              add(scriptContainer); //this shows error
 }

The problem here is that I cannot add the scriptContainer. add(scriptContainer); will not work, because OurServicePopupPixel is a behaviour and not a page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:27:11+00:00Added an answer on June 15, 2026 at 5:27 pm

    Maybe you can simple use a Label component with setEscapeModelStrings(false). But it seems a bit strange.

    I didn’t full understand what is your javascript doing, but maybe you can try to execute it when the DOM is ready. Using a renderHead like this:

    public void renderHead(IHeaderResponse response) {
        response.render(OnDomReadyHeaderItem.forScript( ... YOUR SCRIPT HERE ... ));
    }
    

    I hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
The following code will add the categories selector widget to the WordPress Page editor
I have the following code to add authentication cookie to the response and redirect
The following code can add div elements to the body. But sometimes the HTML
I'm using the following code to add web parts to a page programmatically, however
I use the following code to add TTButton in my loadView method: TTButton* button2
I am using the following code to add some content in an array and
my application has the following code to add a ToSortedList extension method on any
I have this following code to add a button to my custom header for
I'm using the following code to add a displayValue method to NSObject: @interface NSObject

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.