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