Re: Portlets with JavaScript

"Jörn Zaefferer" <[email protected]>
Newsgroups gmane.comp.jakarta.pluto.user
Message-ID <[email protected]>
Concerning event handling and namespace clashes: I can highly recommend
using frameworks like jQuery[1] that make it very easy to select elements
inside other elements. I've written a JSF component that I use for applying
different scripts (often delegating to jQuery plugins) to only a single
portlet. The basic code the component creates looks like this:

<!-- stuff before my own portlet -->
<script type="text/javascript">
jQuery(document).ready(function() {

jQuery("#<%=portletNamespace%>").doSomethingWithOnlyThisPortletEg.find("a").click(function()
{
    // handle click events on anchors only in this portlet
  });
});
</script>
<div id="<%= portletNamespace%>">
<!-- portlet content -->
</div>
<!-- other stuff after my portlet -->

[1] http://jquery.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.