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 8266381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:08:24+00:00 2026-06-08T05:08:24+00:00

in my project i’ve faced a problem with calling javascript code from class wich

  • 0

in my project i’ve faced a problem with calling javascript code from class wich renders
html in wicket.Suppose we have a class ExamplePanel with following code for wicket panel

 public final class ExamplePanel extends Panel {

      public ExamplePanel(String id) {
          super(id);
          add(new Label("someText", "hello"));
      }}

and html file ‘ExamplePanel’

 <html xmlns:wicket>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>ExamplePanel</title>
        <wicket:head>
            <link href="panel.css" rel="stylesheet"/>
            <script src="jquery.min.js"></script>
            <script src="jquery-ui.min.js"></script>

        </wicket:head>
    </head>
    <body>
        <wicket:panel>
            <div id="parentContainer">
                <div id="box" wicket:id="someText"></div>
            </div>
        </wicket:panel>
    </body>
</html>

and following css

    #box{
    background: #f0f0f0;
    width: 50px;
    height: 50px;
    position: absolute;
    top: 200px;
    left: 200px;
    font-size: 1.5em;
    word-wrap: break-word; 
}

#parentContainer{
    width:500px;
    height: 500px;
     background:RGB(57,51,51);
     position:relative;
}

from this code we have box inside the parentContainer div, and i need to pass the position coordinates to box when initialize the ExamplePanel class,
for example :

public ExamplePanel(String id) {
    super(id);
    add(new Label("someText", "hello"));
    // add some code for css positioning of box div
    // $('#div').css({position:'relative',top:'5px',left='29px'}) for example
}

any suggestions?

  • 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-08T05:08:26+00:00Added an answer on June 8, 2026 at 5:08 am

    ExamplePanel must implement IHeaderContributor which provides a method renderHead(IHeaderResponse). From this method, you can call response.renderString() passing it the styles you want to apply. In your case, you are not adding styles, you are adding a JS call that adds some styles. Doing this makes the java call a little more simple because instead of needing to create the as part of the string you render, you will only need to call response.renderJavascript()…

    public class ExamplePanel implements IHeaderContributor {
        public ExamplePanel(String id) {
            super(id);
    
            add(new Label("someText", "hello"));
        }
    
        @Override
        public void renderHead(IHeaderResponse response) {
            // use this if you want to add only the styles
            response.renderString("<style>#div {position:'relative'; top:'5px'; left='29px';}</style>");
    
            // or, use this if you still want the JS selector
            // the uniqueId should not be null if you want Wicket to check if the script has already been rendered
            response.renderJavascript("$('#div').css({position:'relative',top:'5px',left='29px'})", null);
        }
    }
    

    The IHeaderContributor interface is intended to facilitate the addition of Resources such as JavaScript and CSS.

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

Sidebar

Related Questions

Project is C#. So I have a bunch of multithreaded code that is designed
Project Structure I have a silverlight project SLProj, that references a silverlight class library
Project: Winforms, .NET framework: 3.5 (Visual Studio 2008) My problem is: I have a
Project type: Asp MVC 2/NHibernate/C# Problem If you have an edit page in an
ATL project Class>Add>Implement Interface procedure has generated a lot of class functions from IDL
Project: http://design.vitalbmx.com/fave/news.html When I click Add to favorites button (under main pic), in Chrome
This project was coped almost exacatly from the example on the admob page but
My project is ARC enabled (the build settings have Objective-C Reference Counting set to
My project have no visible error but when i try to run it gives
Project CompetitionServer.exe raised exception class ESQLiteException with message 'Error executing SQL. Error [1]: SQL

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.