Guys,

Maybe I'm missing something, but it seems odd that I need to create custom
components in order to set the label on a link. The ability to set the label
(the text the user sees) on a link seems like a very basic use case. Why
would that not be provided in all Link classes?

So far, I've needed to create my own LabeledLink, LabeledSubmitLink and now
it looks like I need to create a LabeledPageLink in order to do what
ExternalLink already provides.

I'm not sure this is the best way to do this, but this is what I've done to
implement a Link that allows the label to be specified.

public class LabeledLink extends Link
{
    protected String label;

    public LabeledLink(java.lang.String id, IModel model, String label)
    {
        super(id, model);
        this.label = label;
    }

    @Override
    protected void onComponentTagBody(final MarkupStream markupStream, final
ComponentTag openTag)
    {
        replaceComponentTagBody(markupStream, openTag, label);
    }
}

Is there a better way?
Am I missing something?

Thanks!
Phil

Reply via email to