简体   繁体   中英

Display a javascript/css tooltip within a @For loop with Tapestry 4.0.1

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

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM