You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jim Pinkham <pi...@gmail.com> on 2011/01/07 17:42:56 UTC

RenderBodyOnly and email links

Many may already have realized this, but for anyone who hasn't, I just came
across this elegant way to handle optional emails.
The user/admin stuff is just an example use-case, simplified to fit here.

// User's Statement page lists some items and who bought them...

    AbstractLink myLink;

    if (isAdminUser()) {
        // admins can view the buyer's full info
        myLink = new BookmarkablePageLink<MemberPage>("buyer.link",
MemberPage.class, params)
    } else {
        // normal users get email links to each other instead
        myLink = new ExternalLink("buyer.link", email);

        // or if they don't have email, just show their name
        myLink.setRenderBodyOnly(email.isBlank());    // if they don't have
an email
    }
    myLink.add(new Label("buyer.name"));

Before I found this, I had two separate elements - the a link with it's span
name inside, and then another span name with only one or the other visible -
that was ugly.

Maybe this helps someone else

Cheers,
Jim
http://togetherauction.com