Okay, in a nutshell and somewhat simplified (composite components actually don't play a role in the problem), your problem is here:
profile.xhtml
:
<my:composite id="interestCmp"> <!-- Yes, invalid code; just to summarize. -->
<h:form id="interestForm">
<h:panelGroup id="showInterests">
...
</h:panelGroup>
</h:form>
</my:composite>
<div class="tabs">
<ul>
<li><a id="tab1" href="tabs/tab1.xhtml">tab1</a></li>
<li><a id="tab2" href="tabs/tab2.xhtml">tab2</a></li>
</ul>
</div>
<script>head.ready(function(){$('.tabs').tabs();});</script>
And somewhere in tab1.xhtml
<h:form id="profileFeeds">
<h:commandLink value="Add">
<f:ajax render=":interestCmp:interestForm:showInterests" />
</h:commandLink>
</h:form>
You're thus using jQuery UI tabs to have a tabbed panel with dynamic content. However, the tab page tab1.xhtml
doesn't share the same JSF view as the main page profile.xhtml
. It are physically completely distinct views. That totally explains why the <f:ajax>
couldn't find the desired component in the component tree (the current view). It can only see components which are contained in tab1.xhtml
itself. It doesn't see those of profile.xhtml
. It can't even see those in tab2.xhtml
.
It will only work if you preload tabs by <ui:include>
instead of dynamically load them. This way the tab1.xhtml
will physically end up in the same view as the desired component. Let's assume that you only need to do that for tab1.xhtml
and the tab2.xhtml
can be kept dynamically loaded. This should then solve your problem:
<div class="tabs">
<ul>
<li><a id="tab1" href="#tab1_page">tab1</a></li>
<li><a id="tab2" href="tabs/tab2.xhtml">tab2</a></li>
</ul>
<div id="tab1_page">
<ui:include src="tabs/tab1.xhtml" />
</div>
</div>
You only need to replace the <?xml...?><!DOCTYPE ...><html xmlns...>
and </html>
of tab1.xhtml
(and actually also tab2.xhtml
) by <ui:composition xmlns...>
and </ui:composition>
respectively. Because otherwise you end up in syntactically invalid HTML.
If you really need to have dynamically/lazily loaded tabs, then you'd better look for a fullworthy JSF component capable of the job, such as PrimeFaces <p:tabView>
. Even more, PrimeFaces uses jQuery/UI under the covers for the look'n'feel, so many things will be very simliar to the current approach.