Works perfectly, thanks!

Op za 26 jun. 2021 om 22:58 schreef Bas Gooren <b...@iswd.nl>:
>
> Hi,
>
> Have a look at TransparentWebMarkupContainer, it was specifically made
> for this. This does involve some (internal) magic in wicket but allows
> you to simply say this.add() in child pages instead of
> rootContainer.add().
>
> // Bas
>
> Verstuurd vanaf mijn iPhone
>
> > Op 26 jun. 2021 om 18:09 heeft Prag Progger <pragprog...@gmail.com> het 
> > volgende geschreven:
> >
> > Hi,
> >
> > I have a ParentPage and many sub class child pages that extend it. I
> > decided to add a root container element to the parent page, but this
> > breaks all ChildPage.add() method calls in the child pages. A solution
> > is to pass the root container to every child, but that is a lot of
> > work. Is there a cleaner way to solve this problem without breaking
> > all the child pages?
> >
> > // ParentPage.java
> > public class ParentPage extends WebPage {
> >    // Shared with sub classes
> >    protected MarkupContainer rootContainer;
> >
> >    public ParentPage() {
> >        rootContainer = new WebMarkupContainer("rootContainer");
> >        add(rootContainer);
> >
> >        rootContainer.add(new Label("parentLabel", "Parent component"));
> >    }
> > }
> >
> > // ParentPage.html
> > <html><body>
> >    <h1>ParentPage</h1>
> >
> >    <div wicket:id="rootContainer">
> >        <p wicket:id="parentLabel"></p>
> >
> >        <div>
> >            <wicket:child />
> >        </div>
> >    </div>
> > </body></html>
> >
> >
> > // ChildPage.java
> > public class ChildPage extends ParentPage {
> >    public ChildPage() {
> >        // This should preferably be add() instead of rootContainer.add()
> >        // So that I don't have such dependency on the parentPage.
> >        rootContainer.add(new Label("childComponent", "Child component"));
> >    }
> > }
> >
> > // ChildPage.html
> > <html><body>
> >    <wicket:extend>
> >        <h2>Child page</h2>
> >
> >        <p wicket:id="childComponent"></p>
> >    </wicket:extend>
> > </body></html>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

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

Reply via email to