Hi Sibgha,
// here is a simple code
//
// in your Dpanel
//
protected void onUpdate(AjaxRequestTarget target) {
send(getPage(), Broadcast.EXACT, new
YourEvent(yourDataFromYourDropDownChoice));
}
//
// in your HomePage, you override the onEvent method
//
@Override
public void onEvent(IEvent<?> event) {
super.onEvent(event);
if (event.getPayload() instanceof YourEvent) {
YourEvent yourEvent = (YourEvent) = event.getPayload();
// the data you sent throw your vent
YourData xyz = yourEvent.getData();
// if you don't neeed anymore your event
event.stop();
}
}
// look at the docs
https://ci.apache.org/projects/wicket/guide/8.x/single.html#_wicket_events_infrastructure
François
follow Apache Wicket on twitter : https://twitter.com/apache_wicket
<https://twitter.com/apache_wicket> !
> Le 26 mai 2019 à 15:33, Sibgha Nazir <[email protected]> a écrit :
>
> Hi,
>
> In my application, Home Page creates DPanel and Dpanel has the drop down
> menu. In the class DPanel at 'onchange' event, I want to do some action
> in the class HomePage.java. How can that be possible?
>
>
> *HomePage.java* public HomePage(final PageParameters parameters)
> {
> super(parameters);
>
> final Panel dropDownPanel = new Dpanel("toReplace");
>
> dropDownPanel.setOutputMarkupId(true);
> add(dropDownPanel);
> }
>
>
> *DPanel.java* public Dpanel(String aId)
> {
> super(aId);
> form = new Form<Void>("form");
> form.setOutputMarkupId(true);
>
> // SelectMenu //
> final DropDownChoice<String> dropdown = new
> DropDownChoice<String>("select", new Model<String>(), new
> ListModel<String>(GENRES));
> dropdown.setRequired(true);
> dropdown.setOutputMarkupId(true);
> dropdown.add(new AjaxFormComponentUpdatingBehavior("change") {
> /**
> *
> */
> private static final long serialVersionUID =
> -6744838136235652577L;
>
> protected void onUpdate(AjaxRequestTarget target) {
> System.out.println("Changed");
>
> }
> });
> .
> .
> .
> .
>
> Quick Start here...
> https://github.com/Sibgha360/dropdownexample.git,