You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sigmar Muuga <me...@gmail.com> on 2010/03/21 17:34:45 UTC

Links and labels

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

Re: Links and labels

Posted by Jeremy Thomerson <je...@wickettraining.com>.
That's what he's saying - write that as a link class and you can use it all
over your app with a single line that creates the link and nested label with
only one line of code.

--
Jeremy Thomerson
http://www.wickettraining.com



On Mon, Mar 22, 2010 at 2:07 AM, Sigmar Muuga <me...@gmail.com> wrote:

> 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 <
> steve.mactaggart@gmail.com> 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
> > <ma...@koodaripalvelut.com> wrote:
> > > Try this:
> > >
> > > <a href="#" wicket:id="link1"><span wicket:id="id"></span></a>
> > >
> > > **
> > > Martin
> > >
> > > 2010/3/21 Sigmar Muuga <me...@gmail.com>:
> > >> 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: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: Links and labels

Posted by Sigmar Muuga <me...@gmail.com>.
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 <
steve.mactaggart@gmail.com> 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
> <ma...@koodaripalvelut.com> wrote:
> > Try this:
> >
> > <a href="#" wicket:id="link1"><span wicket:id="id"></span></a>
> >
> > **
> > Martin
> >
> > 2010/3/21 Sigmar Muuga <me...@gmail.com>:
> >> 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: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Links and labels

Posted by Steve Mactaggart <st...@gmail.com>.
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
<ma...@koodaripalvelut.com> wrote:
> Try this:
>
> <a href="#" wicket:id="link1"><span wicket:id="id"></span></a>
>
> **
> Martin
>
> 2010/3/21 Sigmar Muuga <me...@gmail.com>:
>> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Links and labels

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Try this:

<a href="#" wicket:id="link1"><span wicket:id="id"></span></a>

**
Martin

2010/3/21 Sigmar Muuga <me...@gmail.com>:
> 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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org