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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:58:44+00:00 2026-05-20T05:58:44+00:00

In Wicket 1.4, I’m trying to allow child pages to alter a CSS class

  • 0

In Wicket 1.4, I’m trying to allow child pages to alter a CSS class on a tag in the parent page, which I do all the time. What is odd about this case is that the tag I want to target wraps the child page markup. Here’s a simplified snip of what I tried:

ParentPage.html

<div id="main" wicket:id="main">
  <wicket:child />
</div>

ParentPage.java

public abstract class ParentPage {

  private WebMarkupContainer main;

  protected ParentPage() {
    main = new WebMarkupContainer("main");
    add(main);
  }

  public void setClassAttr(String cssClass){
    main.add(SimpleAttributeModifier("class", cssClass);
  }
}

ChildPage.html

<wicket:extend>
  ...
</wicket:extend>

ChildPage.java

public class ChildPage extends Page {    
   ...

    public ChildPage() {
      super();
      ...     
      setClassAttr("specific-class-for-this-page");
    }
}

…Which blows up because it appears the HTML from the child loads, but not the java. (If I remove the wicket:id and java code on div#main, all is well.)

Note that the tag on the parent that I want to manipulate from the child is actually wrapping the wicket:child tag. In other cases I have done something similar, the tags I want to monkey with tend to be siblings or otherwise distant to the wicket:child tag.

All I really want to do is allow the child to change the class attribute on the parent – is there another way to do this? Why can’t a child page be nested under another Wicket page component?

  • 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-05-20T05:58:44+00:00Added an answer on May 20, 2026 at 5:58 am

    First of all, it has nothing to do with actually setting the attribute, but with putting <wicket:child> inside a container.

    Now imagine if ChildPage was a Panel, what would the code of your ParentPage look like? It would contain a line somewhere saying main.add( new ChildPanel() ). That’s how the main component knows that when it renders, it should call the rendering method of your child panel too.

    But with inheritance it’s different. Your main component has no way of knowing what <wicket:child> should resolve to. Marking your main container transparent tells Wicket to ask the parent component (that is, your page component) to resolve and render it.

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

Sidebar

Related Questions

I am using wicket 1.5.x and trying to load a css file which will
I have a Wicket Web Page where I create a new Object of class
I have a wicket page , which contains two Spring-managed beans , one is
I have a Wicket page class that sets the page title depending on the
I have a Wicket AuthenticatedWebApplication which has several pages and features that need to
I'm new to Wicket and was trying the following configuration: class User { private
Situation In my Wicket application, I have a page which contains two tags. Each
In the Wicket Application class I have mounted a page at the location /about
I am using Wicket 1.5.x with <wicket:head> tag. I tried rendering the child component
In a Wicket Panel i implemented a method called showAttentiePopup(AjaxRequestTarget) which shows an ModalWindow

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.