public class EmailLink extends WebMarkupContainer
{
    private static final long serialVersionUID = 1L;

    public EmailLink(String id, IModel<String> emailAddress)
    {
        super(id, emailAddress);
    }

    @Override
    protected void onComponentTag(ComponentTag tag)
    {
        super.onComponentTag(tag);
        tag.put("href", "mailto:"; + getDefaultModelObjectAsString());
    }

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


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



On Fri, Mar 27, 2009 at 9:21 AM, <[email protected]> wrote:

>   I'm still not seeing how to do this using the ExternalLink component.
> I'm reading the email addresses from a database and using a ListView to
> iterate through them to display on the screen. I added the following to my
> Java file:
>
> item.add(new ExternalLink("email", user.getEmail()));
>
> And the following to my markup:
>
> <a href="#" wicket:id="email"></a>
>
> Obviously, this isn't complete, but I'm not sure what I need to do to get
> it to turn the email address into something like:
>
> <a class="email" href="mailto:[email protected]";>[email protected]</a>
>
>  -------------- Original message from Martijn Dashorst <
> [email protected]>: --------------
>
>
> > The easiest that comes to mind:
> >
> > new ExternalLink("link", "mailto:[email protected]";)
> >
> > Martijn
>
>

Reply via email to