Hi all,
I have just run into a situation where I want to create a
BookmarkablePageLink that changes its class based on some data thats
supplied to it.
For example lets say I had a Customer object that had an "enabled" flag on
it, and we want to have 2 different pages shown for enabled/disabled
customers.
We already have a "CustomerLink" that can be used as such
add(new CustomerLink("customer-link", ourCustomerObject));
CustomerLink extend Bookmarkable link, and will automatically set the label
of the link to be the customers name.
It also, by contract of the BookmarkablePageLink, call super (id,
CustomerViewPage.class).
What I'm interested in knowing is why is the pageClassName in BPL final?
I need to be able to change the pageClassName from CustomerViewPage.class to
CustomerDisabledPage.class when enabled == false.
I do recognise I could probably hack the constructor to do a:
super(id,
customer.isEnabled?CustomerViewPage.class:CustomerDisabledPage.class);
which would probably work in this case, but I have other, much more complex
examples that need to change the page class.
Anyone else run into this? Is there a pattern to get around this issue?
Cheers,
Steve