Sam Hough wrote:
Lots of the time I just want a link with text as the body of the  ... ...

The Link class takes an IModel so presumably uses that for something but I
can't see it in the source or get it to appear...

Sorry I'm being thick and I did search honest!

You'd typically use the model so you have something to get at in the onClick().

Of course, if you don't care about how much state is in your session, you can just make whatever it is final so you can use it in there anyway.

If you want to use the model for the text of the link instead, then you could write a class like this:


public abstract class TextLink extends Link {
    public TextLink(String id, IModel model) {
        super(id, model);
    }

    protected void onComponentTagBody(final MarkupStream markupStream,
            final ComponentTag openTag)
    {
        replaceComponentTagBody(
                markupStream, openTag, getModelObjectAsString()
        );
    }

}


If you want enabled/disabled to work properly, you'll need to copy the relevant bits out of AbstractLink#onComponentTagBody(...)


Regards,

Al

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to