well if you look at the code, the way it works is: only do it if it hasnt
been done already. so this code only does anything on the first attach, then
it becomes a noop.

-igor


On 4/29/07, Rüdiger Schulz <[EMAIL PROTECTED]> wrote:

Hello Igor,

thanks for your help, it was a very close hit :) I actually had to put
the code into internalOnttatch like this:

protected void internalOnAttach() {
super.internalOnAttach();

Component body=get(BodyOnLoadHandler.BODY_ID);
if (body!=null) {
     if (!(body instanceof MyHtmlBodyContainer)) {
          remove(BodyOnLoadHandler.BODY_ID );
          body=null;
      }
}
if (body==null) {
     add(new ...);
}
}

Now I think it works as expected.

Now that I know where to look for this - isn't it that now on every
attach of the page first a new HtmlBodyContainer is created only to
replaced instantly? Is that unnecessary component creation very
costly, or shouldn't I worry about this? I'd rather not like to
overwrite WebPage.getBodyContainer() by copying 99% of the code and
just change the line adding the default HtmlBodyContainer - what I do
seems to be enough of a hack already ;)

greetings,

Rüdiger

2007/4/29, Igor Vaynberg <[EMAIL PROTECTED]>:
> you can most likely move that code to page.onattach() and do
>
> Component body=get(BodyOnLoadHandler.BODY_ID);
> if (body!=null) {
>     if (!(body instanceof MyHtmlBodyContainer)) {
>          remove(BodyOnLoadHandler.BODY_ID );
>          body=null;
>      }
> }
> if (body==null) {
>     add(new ...);
> }
>
> -igor
>
>
> On 4/29/07, Rüdiger Schulz < [EMAIL PROTECTED]> wrote:
> >
> > Hello everybody,
> >
> > I just updated my application from Wicket 1.2.5 to 1.2.6. The update
> > broke one of my pages, which had a rather special requirement: it
> > needed to use my own implementation of HtmlBodyContainer. The way I
> > did it was like this:
> >
> > public EmailPage()
> > {
> >         remove(BodyOnLoadHandler.BODY_ID);
> >         add(new MyHtmlBodyContainer(BodyOnLoadHandler.BODY_ID);
> > }
> >
> > see also:
> >
> http://www.nabble.com/BodyContributor--tf2578291.html#a7187578
> >
> > With 1.2.6 this does not work anymore. The remove throws the following
> > Exception:
> >
> > Caused by: wicket.WicketRuntimeException: Unable to find a component
> > with id '_<body>' to remove
> >         at wicket.MarkupContainer.remove(MarkupContainer.java:479)
> >
> > Just doing the add without the remove doesn't work either:
> >
> > Caused by: java.lang.IllegalArgumentException: A child
> with id
> > '_<body>' already exists:
> > [Page class = de.indyphone.logokits.wicket.ComposerPage,
> id = 21]
> >         at wicket.MarkupContainer.add(MarkupContainer.java:156)
> >         at
> wicket.markup.html.WebPage.getBodyContainer(WebPage.java:211)
> >         at
> wicket.markup.html.WebPage.internalOnAttach(WebPage.java:175)
> >         at wicket.Component.internalAttach(Component.java:2572)
> >         at
> wicket.MarkupContainer.internalAttach(MarkupContainer.java:341)
> >
> > So, where's the best location to put the code for replacing the
> > BodyContainer? And will this then still work in 1.3?
> >
> > Thanks for your time,
> >
> > Rüdiger
> >
> >
>
-------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to