You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Noam Solomon <ns...@shopping.com> on 2005/11/16 16:24:43 UTC

T4.0 beta 12 PopupLinkRenderer problem: is it a bug?

I've been trying to set up a popup link column in a contrib:table.  I
did finally succeed, but I had use my own hacked copy of
org.apache.tapestry.contrib.link.PopupLinkRenderer as a replacement.  Am
I missing something?

 

Originally, I managed to do it with an ITableColumnModel and a custom
renderer, but I was advised to use a contrib:PopupLink block in the
template.  So, first problem: the "tapestry-contrib-4.0-beta-12.jar" in
my distribution didn't come with "PopupLink".  Was I supposed to
download a separate file to get it?  My assumption looking through the
jar file was that it was deprecated for some reason, and that I should
use the similar-sounding PopupLinkRenderer instead.

 

The second problem took me a long time to sort out.  In the template I
set up a GenericLink component, and passed it a PopupLinkRenderer bean
as a parameter.  In the table column block I use the GenericLink
component.  It worked, but it did not write a popup link, just a regular
link.  I made my own copy of PopupLinkRenderer and added debugging
statements to it, and noticed that constructURL was never called.  This
was a surprise!  The reason was that org.apache.tapestry.contrib.link
PopupLinkRenderer only has this constructURL method:

 

   protected String constructURL(ILink link, String anchor,
IRequestCycle cycle)

 

whereas the renderLink() method in
org.apache.tapestry.link.DefaultLinkRenderer (the one called by
renderComponent() in AbstractLinkComponent, the base class of
GenericLink et al.,) the call to constructURL() looks like this:

 

  writer.attribute(getUrlAttribute(), constructURL(linkComponent,
cycle));

 

this is a different constructURL() method, and is defined in the
DefaultLinkRenderer class, so the popupLinkRenderer's constructURL()
method wasn't being called.  My solution was to add an "adapter"
override to my version of PopupLinkRenderer:

 

    protected String constructURL(ILinkComponent lc, IRequestCycle
cycle) {

            return constructURL(lc.getLink(cycle), lc.getAnchor(),
cycle);

    }

 

This works fine, but obviously is a hack.  Please advise!