Wicket: Modal Windows and callback functionality

733 views Asked by At

I have a modal window that shows a panel which contains a form that has some textfields and a submit button

on submit an insert into the database occurs and then I have some ajax behaviour that i want to activate on the modal windows containing page on click of the button.

So flow is at present:

  1. click link
  2. modal window appears
  3. user fills out form
  4. user submits form
  5. form data persisted to db
  6. modal window closes

I need it to do this in addition:

  1. activate some ajax behaviour on the page that contains the panel

any help on how best to do this in the wicket way is appreciated.

2

There are 2 answers

1
OnesAndZeros On

I resolved this by passing an instance of the page containing the panel to the panel (i.e. - in the constructor), then calling a method on the page from the panel to perform the Ajax update.

I would be interested to see what others have done or to hear if there are issues with the approach I have taken.

0
Volksman On

Set up a WindowClose callback.

In the WicketStuff project called ModelX (Disclaimer: I'm the developer of that) I have created an IWindowClosedListener interface which has a method:

void windowClosed(Panel panel, AjaxRequestTarget target)

So then any Page or Panel that can open a modal that needs to do something when that modal is closed simply implements that interface and its windowClosed method gets called at the right time.