package ca.krasnay.panelized;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

public class BookmarkablePageLinkPanel extends Panel {

    private static IModel<String> getDefaultPageTitle(PageRef pageRef) {

        if (pageRef.getPageClass().isAnnotationPresent(PageTitle.class)) {
            return Model.of(pageRef.getPageClass().getAnnotation(PageTitle.class).value());
        } else {
            throw new RuntimeException("Page " + pageRef.getPageClass().getName() + " does not have a @PageTitle annotation");
        }
    }

    public BookmarkablePageLinkPanel(String panelId, PageRef pageRef) {
        this(panelId, getDefaultPageTitle(pageRef), pageRef);
    }

    public BookmarkablePageLinkPanel(String panelId, IModel<String> linkText, PageRef pageRef) {

        super(panelId);

        BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>("link", pageRef.getPageClass(), pageRef.getPageParameters());
        add(link);

        link.add(new Label("text", linkText));

    }
}

@@ -258,23 +258,154 @@
 t.model.
-Model;%0A
+ResourceModel;%0A%0A/**%0A * Panel containing a link to a bookmarkable page.%0A *%0A * @author %3Ca href=%22mailto:john@krasnay.ca%22%3EJohn Krasnay%3C/a%3E%0A */
 %0Apublic 
@@ -618,24 +618,23 @@
     
-return Model.of(
+String value = 
 page
@@ -690,16 +690,67 @@
 .value()
+;%0A            return new ResourceModel(value, value
 );%0A     
@@ -897,32 +897,376 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * Constructor that uses the page's %7B@link PageTitle%7D annotation to determine%0A     * link text. The value of the %7B@link PageTitle%7D annotation is used to look%0A     * up a string resource with that key. If not found, the value itself is%0A     * displayed, so the value can contain the page title directly for monolingual apps.%0A     */%0A
     public Bookm

Make PageTitle annotation localizable