There are several reasons:

* That would make the link too limited. It is a WebMarkupContainer,
meaning you can put an image, label, panel, table, div, fragment,
border, etc inside the link.

* The previewability would suffer and it add too much magic: what
would you do with text already inside the link? setLabel() would
override the contents, but if I have <a href="#"
wicket:id="foo">Foo</a> and in Java new Link("foo").setLabel("bar").
Now if my designer comes along and changes the text inside the <a
href>.
* Or other components? What would happen if you setLabel when there is
a component inside the link?
* It adds another way of working with components. This is how we want
to grow the api: providing 20000 different ways of doing the same
thing.

And btw, most examples directly put a Label into the link, not panels:
the span is there for the Label.

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

add(new Link("personlink") { ...}.add(new Label("name"));

It is easy to add what you want yourself in a custom component
(provided you use Wicket 1.3), override oncomponenttagbody:

public abstract class LabelLink extends Link {
    private IModel labelModel;

    public LabelLink(String id, IModel linkModel, IModel labelModel) {
        super(id, linkModel);
        this.labelModel = labelModel;
    }
        protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
        {
                replaceComponentTagBody(markupStream, openTag,
labelModel.getObject().toString());
        }
}

On 5/25/07, Ravindra Wankar <[EMAIL PROTECTED]> wrote:
>
> In a table of contacts I want to make the "Name" a hyperlink to the page
> that displays details of that contact. So I created a link and wanted to
> set the label of the link to the name of the contact. I could not find a
> suitable method on the Link classes. All examples I saw create a panel
> inside the link tag and then set a label inside the panel. Why is it not
> possible to call setLabel() directly on a link or is there a way I'm not
> aware of?
>
> Thanks
> Ravi.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>


-- 
Join the wicket community at irc.freenode.net: ##wicket
Wicket 1.2.6 contains a very important fix. Download Wicket now!
http://wicketframework.org

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to