getpageclass() is final because the class takes the destination page
class as a constructor arg, and so it would be weird to let the users
break the contract so easily.

also, it is a trivial class, and it is trivial to make your own:

class mybpl extends link<customer> {
  public final void onclick() { //noop }
  protected charseq geturl() {
     customer c=getmodelobject();
     if (c.enabled()) { return urlfor(somepage.class); }
     else { return urlfor(otherpage.class);}
   }
}

-igor


On Tue, May 25, 2010 at 8:58 PM, Steve Mactaggart
<[email protected]> wrote:
> 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
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to