paste your entire panel/page class... -igor
On Wed, Mar 28, 2012 at 12:15 PM, Jeffrey Schneller <[email protected]> wrote: > Thanks. But what does OuterPanelClass refer to in my example? > > I don't think either of these are right: > > MyEmptyPanel.this.panel.replaceWith(replacement); > -or- > MyPage.this.panel.replaceWith(replacement); > > Or do I need to define workingPanel as a private member of my page class and > then have: > > MyPage.this.workingPanel.replaceWith(replacement); > MyPage.this.workingPanel = replacement; > > > > > > > -----Original Message----- > From: Igor Vaynberg [mailto:[email protected]] > Sent: Wednesday, March 28, 2012 3:07 PM > To: [email protected] > Subject: Re: Event handling and swapping panels > > OuterPanelClass.this.panel.replaceWith(replacement); > OuterPanelClass.this.panel=replacement; > > -igor > > On Wed, Mar 28, 2012 at 11:33 AM, Jeffrey Schneller > <[email protected]> wrote: >> I want to swap panels using the event model in 1.5. This is very similar to >> the panel swapping code (wicket 1.4.x) found in the Apache Wicket Cookbook >> but uses the event model instead. The problem is I can't set the panel >> equal to its replacement, like you would in 1.4.x. This is found on the >> line marked ***** THIS IS NOT POSSIBLE *****. >> >> How would you go about doing this? Is it even possible? >> >> Component workingPanel = new MyEmptyPanel("workingPanel") { >> @Override >> public void onEvent(IEvent<?> event) { >> if (event.getPayload() >> instanceof MyPanelEvent) { >> >> MyPanelEvent e = (MyPanelEvent) event.getPayload(); >> >> Component replacement; >> switch >> (e.getType()) { >> >> case >> MyPanelEvent.PANEL1: >> >> replacement = new MyFirstPanel(this.getId()); >> break; >> default: >> >> replacement = this; >> break; >> } >> >> this.replaceWith(replacement); >> this. = replacement; >> // ****** THIS IS NOT POSSIBLE - HOW WOULD I DO THIS ******* >> >> this.setOutputMarkupId(true); >> AjaxRequestTarget >> target = e.getTarget(); >> target.add(this); >> } >> super.onEvent(event); >> } >> workingPanel.setOutputMarkupId(true); >> add(workingPanel); >> >> AjaxLink firsttab = new AjaxLink("firsttab") { >> @Override >> public void onClick(AjaxRequestTarget target) { >> send(getPage(), Broadcast.BREADTH, new >> MyPanelEvent (target, MyPanelEvent.PANEL1)); >> } >> }; >> firsttab.setOutputMarkupId(true); >> firsttab.setMarkupId("firsttab "); >> add(firsttab); >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
