I think that the last sample is too complicated. Wicket is meant to be
simple, I dont want to write 100 lines of code because of one simple
link.....

On Mon, Mar 22, 2010 at 1:26 AM, Steve Mactaggart <
[email protected]> wrote:

> The other way I have implemented that in our local code is to create a
> LabeledBookmakableLink.
> This link takes a 4th parameter that is the label to display. Then
> override the onComponentTagBody to rewrite the contents of the <a> tag
> to put in the content.
>
> Code looks like:
>
>    public LabeledBookmarkableLink(String id, Class pageClass,
> PageParameters parameters, IModel<String> label) {
>        super(id, pageClass, parameters);
>        this.label = label;
>    }
>
>    protected void onComponentTagBody(MarkupStream markupStream,
> ComponentTag openTag) {
>        if (label != null && label.getObject() != null) {
>            replaceComponentTagBody(markupStream, openTag,
> label.getObject());
>        }
>        else {
>            super.onComponentTagBody(markupStream, openTag);
>        }
>    }
>
> Cheers,
>
> Steve
>
> On Mon, Mar 22, 2010 at 3:37 AM, Martin Makundi
> <[email protected]> wrote:
> > Try this:
> >
> > <a href="#" wicket:id="link1"><span wicket:id="id"></span></a>
> >
> > **
> > Martin
> >
> > 2010/3/21 Sigmar Muuga <[email protected]>:
> >> Hello, does anybody know, how to add label to links?
> >>
> >> I have markup like this:
> >>
> >> <a href="#" wicket:id="link1">[link label goes here]</a>
> >>
> >> Now in java I want to do something like this:
> >>
> >>        Link<Object> link = new BookmarkablePageLink<Object>("link1",
> >> HomePage.class, regParams);
> >>        link.add(new Label(id, "Register here!")); // this must be so,
> >> because I want to change this label runtime
> >>
> >> Sigmar
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to