On Wed, 11 Jun 2008, freak182 wrote:
> I already rip out your patch and run the testcase it worked but how can i
> implement/intgerate to my project...do you have a working example project
> for that?
Unfortunately not, but just copy the classes to a suitable
package in your project and start using them in the same way
as in the test cases.
E.g. something along these lines
public class FooSelectionEvent implements Event {
private final IModel foo;
private final AjaxRequestTarget target;
public FooSelectionEvent(IModel foo, AjaxRequestTarget target) {
this.foo = foo;
this.target = target;
}
public Foo getFoo() {
return (Foo) foo.getObject();
}
public void addToTarget(Component c) {
target.addComponent(c);
}
}
public interface FooSelectionReceiver extends EventReceiver {
void onEvent(FooSelectionEvent event);
}
public class SelectedFooLabel extends Label implements FooSelectionReceiver {
...
public void onEvent(FooSelectionEvent event) {
setModelObject(event.getFoo());
event.addToTarget(this);
}
}
public class FooPanel extends Panel {
private EventBroadcaster broadcaster = new EventBroadcaster(this);
...
add(new DropDownChoice("fooSelection", fooSelection, fooList)
.add(new AjaxFormComponentUpdatingBehavior("onchange") {
public void onEvent(AjaxRequestTarget target) {
broadcaster.broadcast(FooSelectionReceiver.class, new
FooSelectionEvent(target, fooSelection));
}
});
...
}
Now SelectedFooLabel receives the events sent from the
DropDownChoice, provided that both component instances are on
the same page (you must be careful with repeater items and
other replaced components here).
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]