THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block |
---|
public class MyPopupCloseLink extends PopupCloseLink { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("onclick", "window.parent.refresh();"); } } |
Opening a modal window on page load (no AJAX involved)
If you need to open up a modal window when a page is loaded following extension of ModalWindow class will do the trick.
Code Block |
---|
/**
* @author Ernesto Reinaldo Barreiro
*/
public class OpenOnLoadModalWindow extends ModalWindow implements
IHeaderContributor {
private static final long serialVersionUID = 1L;
/**
* @param id
*/
public OpenOnLoadModalWindow(String id) {
super(id);
}
/**
* @param id
* @param model
*/
public OpenOnLoadModalWindow(String id, IModel<?> model) {
super(id, model);
}
/**
* Adds the JavaScript to initially open modal window.
*/
public void renderHead(IHeaderResponse response)
{
response.renderOnDomReadyJavascript(getWindowOpenJavascript());
}
/*
* (non-Javadoc)
* @see org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow#makeContentVisible()
*/
@Override
protected boolean makeContentVisible()
{
return true;
}
}
|
The trick boils down to doing two things:
-Making sure the contents of the modal window are visible on initial rendering (makeContentVisible())
-Making sure the JavaScript opening the modal window is executed when page is loaded.
// TODO : Add other examples