There's a simple way to set a limit for max. opened pages.
You have to override some methods of your Dispatcher class which inherits from WorkpageDispatcher.
Code:
/**
* This constructor is called initially
*/
public Dispatcher() {
super();
// Limit nr. of max opened pages
getWorkpageContainer().setMaxNumberOfWorkpages(Constants.MAXWORKPAGES);
//getWorkpageContainer().setMaxNumberOfWorkpagesExceededMessage("My own message!");
}
/**
* This constructor is called when a new workpage is opened
* @param workpageContainer
*/
public Dispatcher(IWorkpageContainer workpageContainer) {
super(workpageContainer);
int openedPages = workpageContainer.getAllWorkpages().size();
System.out.println(openedPages + " Workpages opened!");
for(Object obj : workpageContainer.getAllWorkpages()) {
Workpage wp = (Workpage)obj;
System.out.println(wp.getTitle());
}
if(openedPages >= Constants.MAXWORKPAGES) {
Workpage wp = (Workpage)workpageContainer.getAllWorkpages().get(0);
workpageContainer.getAllWorkpages().remove(0);
System.out.println("Close " + wp.getTitle());
wp.closeForced();
}
}
If you just want to limit the amount, it's enough to override Dispatcher(), when the user exceeds the number of pages, he gets a popup.
If you want to do further manipulations in your workplace you can override Dispatcher(IWorkpageContainer), this constructor is called everytime a new page is opened!