In my wicket application, Page navigation is by creating new Page object by calling the constructor of the new Page on the onClick() methods. As below.
DisplayItem.add(new Link("edit") {
@Override
public void onClick() {
try{
setResponsePage(new ReportPage(object, getPageReference()));
} catch ( CustomException e){
/// set some feedback message
}
}
});
ReportPage has several LoadableDetachableModels, PageableListViews, Panels, Fragments etc. I am doing exception handling in the constructor of the ReportPage and throws it back if an exception occurs. Ses below. ( partial code )
public ReportPage(final Objectm, final PageReference pr) throws CustomException{
try{
final LoadableDetachableModel<MaintReport> ldm =
new LoadableDetachableModel<MaintReport>() {
@Override
protected MaintReport load() {
return new MaintReport();
}
};
/*
Several LoadableDetachableModels, PageableListViews, Panels, Fragments etc.
*/
} catch ( Exception ex){
// create Custom Exception
} finally {
// Clean up of stuff
}
So if an exception occurs in constructing the page. How should I do clean up ( in the finally block ) ? . Should I set all the individual objects to null ? Is there any Wicket method to garbage collect ( or send signal to GC) ?
Thank you