Jerry,

the wiki has an example: http://wicket-wiki.org.uk/wiki/index.php/Markup_inheritance


Timo


Igor Vaynberg schrieb:
with markup inheritance you wouldnt need a separate border that wraps all
the pages, simply move everything that is in the border into the basepage
instead.

-Igor


On 5/19/06, Jerry Smith <[EMAIL PROTECTED]> wrote:

Thanks for the reply Igor! I'll try the methods you mentioned. You also said markup inheritance is a better fit for this use case, could demonstrate
how you would do this? I thought I was using markup inheritance, but it
appears I don't fully understand how to set it up correctly.  Thanks!



-Jerry


  ------------------------------

*From:* [EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED] *On Behalf Of *Igor Vaynberg
*Sent:* Friday, May 19, 2006 2:03 PM
*To:* wicket-user@lists.sourceforge.net
*Subject:* Re: [Wicket-user] Border and markup inheritance problem



if you look at the hierarchy of your message label it is like this:

in java:

page->message

in markup:

page->border->message

so when wicket tries to render message in the markup it cannot find it
because it expects it to be in the border, but in fact you have added it to
the page itself in extendpage.

so what you should do is either someting like this

ExtendPage() { getBorder().add(message); } to put it in the right place

or

BasPage() { add(new MyBorder("blah").setTransparentResolver(true); } this
will tell wicket that the border is transparent - if component inside border
cannot be found wicket should try to locate it in the border's parent

or use markup inheritance which is a much much better fit for this usecase

-Igor


 On 5/19/06, *Jerry Smith* < [EMAIL PROTECTED]> wrote:

Sorry to send this again, I know you're all very busy trying to get the
1.2 release together, but I didn't want this to fall through the cracks if
it is a bug.



I'm get a "WicketMessage: Unable to find component with id 'message'"

error. Maybe this can't be done or I'm doing it wrong using 1.2rc4, but
what I'm working with is a MyBorder component, a BasePage, and ExtendPage.
Here's the distilled code bits:



MyBorder.html:

<wicket:border>

    <div wicket:id="header">[header]</div>

    <div>

        <wicket:body/>

    </div>

    <div wicket:id="footer">[footer]</div> </wicket:border>



MyBorder.java:

public class MyBorder extends Border {

    public MyBorder(String id) {

        super(id);

        add(new Label("header", new Model("Border Header")));

        add(new Label("footer", new Model("Border Footer")));

    }

}



BasePage.html

<html>

    <body>

        <div wicket:id="border">

            <wicket:child/>

        </div>

    </body>

</html>



BasePage.java

public class BasePage extends WebPage {

    public BasePage() {

        add(new MyBorder("border"));

    }

}



ExtendPage.html:

<wicket:extend>

    <span wicket:id="message">[message]</span>

</wicket:extend>



ExtendPage.java:

public class ExtendPage extends BasePage {

    public ExtendPage() {

        super();

        add(new Label("message", new Model("Extended message")));

    }

}



Here's the error output minus stack:

<html>

    <head>

        <title></title>

    </head>

    <body>

        <div wicket:id="border">

            <wicket:child><wicket:extend>

    <span wicket:id="message">[message]</span>

</wicket:extend></wicket:child>

        </div>

    </body>

</html>



[Page class = ExtendPage, id = 4]:

#     Path                    Size        Type
                                          Model Object

1    _<body>                 2.7K
wicket.markup.html.internal.HtmlBodyContainer

2    _header                 473 bytes
wicket.markup.html.internal.HtmlHeaderContainer

3    border                  1.3K
com.ses.wicket.components.test.x.MyBorder

4    border:_child           485 bytes
wicket.markup.html.WebMarkupContainer

5    border:_child:_extend   456 bytes
wicket.markup.html.WebMarkupContainer

6    border:footer           456 bytes   wicket.markup.html.basic.Label
              Border Footer

7    border:header           456 bytes   wicket.markup.html.basic.Label
              Border Header

8    message                 460 bytes   wicket.markup.html.basic.Label
              Extended message





From this it looks like the "message" Label isn't being added to the
correct component(border:_child:_extend?), am I doing something wrong, or is
this a bug?



Thanks for any input!



-Jerry









-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to