but if you remove it
how can it be a target again for an ajax event? or that never happens?

What you can use is try to add it as auto add..
So create an auto add component, we will remove those for you

johan


On Tue, May 6, 2008 at 9:38 PM, Erik van Oosten <[EMAIL PROTECTED]>
wrote:

> Hello Johan et all,
>
> Ok, I see the problem. But let me then propose a change to the exception
> text. Something like "can not change hierarchy after render phase has
> started". I'll create a Jira issue if you like.
>
> But why? Well, its one of the things I tried in a long list of attempts to
> do custom Ajax things. More experienced Wicketeers can probably point me in
> more productive directions.
>
> I have this set up where custom javascript uses the result of an Ajax
> response and places it in a modal window (or on other places in the page).
> Why? Well, our html/javascript designer refuses to use the wicket ajax
> libraries but writes everything himself. The only thing he trusts is jquery.
>
> So I worked around this by creating my own Ajax behaviors (which is pretty
> easy as you can easily get the URL that should be called from the client). I
> reused AjaxRequestTarget to generate the response. Now AjaxRequestTarget
> wants the component that is rendered to be a part of the current page. I
> therefore add the panel to be rendered to the page, even if it is not really
> used like that in the client code (as with the modal window). Therefore, at
> some moment it needs to be removed again as well.
>
> For removal I have 2 cases:
> -1- the modal window contains a form, the form might be submitted, so the
> server gets feedback.
> -2- the modal window only displays some information or the form is not
> submitted, the server gets no feedback on the close of the modal window
>
> For case -2- (in my earlier attempts) I tried to remove the component in
> onAfterRender. After realizing that this doesn't work, I did it in the
> onBeforeRender when some flag was set (accepting that it can be stored in
> the session for some time).
> But I only just realize that this case could be solved a lot better by
> using a Page instead of a Panel to deliver the content for the modal window.
>
> In case -1- however, I need to update the page that initiated the modal
> window. As we're not allowed to keep references between pages (because of
> the disk store's serialization tricks), I add the modal window panel to the
> page (with the form on it), and remove it again within the ajax-submit of
> the form. In the same onSubmit I update some components on the page,
> re-render them (again using AjaxRequestTarget) and pass them back to the
> client.
> This works, but when the form is not submitted, the modal window panel is
> never removed from the page. After a couple of such closes, the response
> time of the page easily explodes to half a minute.
>
> Ideally I would use a Page for the model window's content as well.
> However, I see no way to get a reference to the page it was opened from.
>
> Can anyone shine a little light on this? Is it possible to get that page
> reference? How does Wicket's modal window do this?
>
> Regards,
>   Erik.
>
>
>
>
> Johan Compagner wrote:
>
> > Why do you want to do that?
> > The problem is if you affect the page then the page version is
> > affected. So all what is rendered now isnt really the state wat the
> > page has.
> > Thats why you get that exception when rendering has started.
> >
> > On 5/6/08, Erik van Oosten <[EMAIL PROTECTED]> wrote:
> >
> >
> > > Hi,
> > >
> > > When I try to change the component hierarchy in onAfterRender I get an
> > > exception with the text "can not change hierarchy *during* render
> > > phase". Why is this? Isn't the render phase finished in
> > > on*After*Render?
> > >
> > > Regards,
> > >    Erik.
> > >
> > > --
> > > Erik van Oosten
> > > http://day-to-day-stuff.blogspot.com/
> > >
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to