The panel containing the behavior hasn't been added to the page (yet)
on panel constructor so you can't compute the path (UTL) to the
behavior. That's why you have to to use the methods suggested by
Martin.

Ernesto

On Mon, Oct 4, 2010 at 4:38 PM, monzonj <monz...@gmail.com> wrote:
>
> Hi.
> I'm still trying to understand how Wicket works, and I still don't get many
> things, specially related to the code we can / can't place in a page/panel
> constructor.
>
> I've got this case I don't understand, perhaps you guys have an idea what's
> going on.
>
> Imagine this test application:
>
> -------------------------------------------------
>
> public class TestApp extends WebApplication {
>   �...@override
>    public Class<? extends Page> getHomePage() {
>        return HomePage.class;
>    }
> }
>
> -------------------------------------------------
>
> public class HomePage extends WebPage {
>    public HomePage() {
>        TestPanel p = new TestPanel("myPanel");
>        add(p);
>    }
> }
>
> -------------------------------------------------
>
> ((HomePage.html))
> <body>
>    <div wicket:id="myPanel"></div>
> </body>
>
>
> -------------------------------------------------
>
>
> public class TestPanel extends Panel {
>    public TestPanel(final String id) {
>        super(id);
>
>        AbstractDefaultAjaxBehavior behavior = new
> AbstractDefaultAjaxBehavior(){
>            protected void respond(final AjaxRequestTarget target) {
>                //not important for the test
>            }
>        };
>
>        add(behavior);
>        behavior.getCallbackUrl()); //Runtime exception. No Page found for
> component :(
>    }
> }
>
>
> If you run this example, you get:
>
> java.lang.IllegalStateException: No Page found for component
> [MarkupContainer [Component id = myPanel]]
>     at org.apache.wicket.Component.getPage(Component.java:1819)
>
> The method getPage returns null. Why? Where Am I supposed to make the call
> getCallBackUrl() if not in the constructor?
>
> Any help will be most appreciated,
> Thanks.
>
>
>
>
>
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/AbstractDefaultAjaxBehavior-getCallbackUrl-throws-a-Runtime-Exception-tp2954440p2954440.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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