Thursday, November 30, 2006
The First Braindead Thing I've Seen in Wicket
ListView
.Getting a list of links to display in a
ListView
is easy enough. The downside is that to change the contents of the text of a link, you have to include inside it a <span> element and assign to that a Label
and then change the contents of that. This seemed like a lot of running around just to change the contents of a PageLink
to me, so I figured I'd have a go at simply extending PageLink
to something that can set the contents of the body of the link tag to any arbitrary string.The normal way one would do this is by overriding the
onComponentTagBody
method, but unfortunately doing this for PageLink
is impossible. For whatever braindead reason, Wicket makes onComponentTag
and onComponentTagBody
final inside Link
.This is incredibly short-sighted if not outright stupid. There are a myriad of reasons why someone (like me) might want to extend the behavior of a
Link
, including the way the <a> tag and its body are rendered. Maybe one wants to add some random Javascript behavior, change the contents of the tag body, add a dynamic title
attribute, etc. All impossible because someone made these methods final (for no good reason that I can see).Stupid.
Labels: software
http://wicket.sourceforge.net/faqs.html#why-final
The logic behind the final is to prevent extending something that hasn't been designed for extending. Not that I agree with it. Just cutting and pasting links.
<< Home
Subscribe to Posts [Atom]