Hello, Thats a great patch...it is already been updated in wicket-extensions? so i can download it?
Thanks a lot...Cheers. Timo Rantalaiho wrote: > > On Mon, 09 Jun 2008, freak182 wrote: >> Im having problem of updating parents components.Hereis my problem, there >> is >> page and in that page there is a panel. The panel contain a >> FormUpdatingComponent that attached to a dropdownchoice. Now when the >> dropdown is triggered, i want to update the parents (the page) >> textbox/label..is this possible? > > Hmm, what is FormUpdatingComponent?-) A typo perhaps? > > Sure it is possible, e.g. something like > > public class FooPage extends WebPage { > public FooPage() { > Panel fooPanel = new FooPanel("fooPanel", ... > .... > Foo initialSelection = ... > IModel fooModel = new Model(initialSelection); > final Label display = new Label("foo", fooModel); > display.setOutputMarkupId(true); > add(display); > DropDownChoice selection = new DropDownChoice("fooSelection", > fooModel, choices); > selection.add(new AjaxFormComponentUpdatingBehavior("onchange) { > public void onEvent(AjaxRequestTarget target) { > target.addComponent(display); > } > }); > fooPanel.add(selection); > ... > } > } > > But if your Panel is "further away" from the other > components directly on the page, this might get trickier. > For normal requests you can often get away with sharing the > model, but if passing it all the way to the "sending" > component gets nasty, or if you want to repaint something in > the parent via Ajax, something like this might be easier > > public interface FooChoiceListener { > void onSelection(IModel foo, AjaxRequestTarget target); > } > > public class MyLabel extends Label implements FooChoiceListener { > ... > public void onSelection(IModel foo, AjaxRequestTarget target) { > setModelObject(foo.getObject()); > target.addComponent(this); > } > } > > > public class FooPage extends WebPage { > public FooPage() { > Label display = new MyLabel(...); > add(new FooPanel()); > ... > } > } > > public class FooPanel extends Panel { > public FooPanel(String id, IModel foo) { > ... > DropDownChoice selection = new DropDownChoice("fooSelection", > fooModel, choices); > selection.add(new AjaxFormComponentUpdatingBehavior("onchange) { > public void onEvent(AjaxRequestTarget target) { > getPage().visitChildren(FooChoiceListener.class, > new IVisitor() { > public Object component(Component c) { > ((FooChoiceListener) c).onSelection(fooModel, target); > return CONTINUE_TRAVERSAL; > } > }); > } > }); > } > } > > A "generic eventbroadcaster" can be found here > > http://issues.apache.org/jira/browse/WICKET-1312 > > Best wishes, > Timo > > -- > Timo Rantalaiho > Reaktor Innovations Oy <URL: http://www.ri.fi/ > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/How-to-update-parent-component-from-a-panel--tp17748294p17749764.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]