views:

363

answers:

2

I'm not at all familiar with Tapestry 4.0.1 and need to update a legacy application to display a formatted tooltip for a few links within a @For loop. What is the easiest/best way to go about accomplishing this? Should I be using the @Script component or is there a simpler way?

By the way, upgrading to a newer version of Tapestry is out of the question. Unfortunate, yes, but out of my control.

Thanks in advance for your help.

Carl

A: 

After posting my question, I managed to come up with a rather hacky (crappy?) solution. Can't say it's my proudest moment as a engineer, but it works.*

<script type="text/javascript">
    function outputLink(value, tooltip) {
            document.write("<a href='#' onclick='return false;' onmouseover='showtip(event, \"" + tooltip + "\");' onmouseout='hidetip();'>" + value + "</a>");
        }
</script>
<span jwcid='@For'>
    <script type="text/javascript">
        outputLink("Foo", "<span jwcid="@Insert" value="ognl:foo.bar"/>");
    </script>
</span>

*Some code omitted to protect the innocent.

carlsz
IIRC, using the dom to update the structure is preferred to a straight document.write(...)CMA: There was something along the lines of DOM/document.write posted here on SO a while ago
Everyone
A: 

Use the @Any component. For your example, substitute MYTOOLTIP with whatever object is holding the message:

<a jwcid="@Any" id="adUnitPredicate" href="#" onclick="return false;" onmouseover="ognl:'showtip(event, \'' + MYTOOLTIP + '\');'" onmouseout="hidetip();">AdUnit Predicate</a>
Civil Disobedient