You just add both the link and the text to your page with setVisible(false).
Then setVisible(true) on the one you want to show.

Regards,
kjarbr

 


On 15.08.10 15.40, "Michael Brinkman" <michael.brink...@gmail.com> wrote:

> My apologies if this has been answered a thousand times before but I haven't
> been able to find anything in searching, so your thoughts would be
> appreciated.
> 
> I have a very simple scenario where I have an anchor tag associated with a
> wicket link that wraps a static image like this:
> 
> <a wicket:id="myLink">Link Text</a>
> 
> In some cases, I would like to swap this anchor tag and it's body with a
> &nbsp; since it's in a table.  So I've used setEnabled(false) on the
> associated Link instance to cause the anchor tag to be swapped with a span
> and then I overrode the onComponentTagBody method on the Link like so:
> 
>                 protected void onComponentTagBody(MarkupStream markupStream,
> ComponentTag openTag)
>                 {
>                     //    Only render the body if the link is enabled
>                     if (this.isEnabled())
>                     {
>                         super.onComponentTagBody(markupStream, openTag);
>                     }
>                     else
>                     {
>                         //    Write out a space and then move to the
> matching close tag of the original link.  Even though
>                         //    the open tag has been renamed to "span" by
> being disabled, the framework will take care of renaming the
>                         //    close tag as well.
>                         getResponse().write("&nbsp;");
>                         markupStream.skipToMatchingCloseTag(openTag);
>                     }
>                 }
> 
> So what comes out is a little more verbose than just a non breaking space:
> 
> <span>&nbsp;</span>
> 
> Any thoughts on a better approach to this would be appreciated. I'm really
> interested in this because I find it to be a generally useful thing to know
> how to do and I suspect there's probably already a simpler way to swap a
> wicket rendered tag for something else that I just don't know about.
> 
> Thanks,
> 
> -Michael



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

Reply via email to